Is it possible to post PHP code by an html form and then run it as PHP?
something like this
<form action="#" method="post">
<textarea name="code"></textarea><br>
<input type="submit" value="Run!">
</form>
<?php
if (!empty($_POST['code'])) {
$_POST['code']; // Run the Posted PHP code here
}
?>
so if i type
<?php echo 'this is a test'; ?>
in my textarea and then send the form it will echo "this is a test" out
EDIT AFTER ANSWERS
thank you guys i didn't knew eval() function, i guess i can also do this for security against hackers:
<form action="#" method="post">
<textarea name="code"><?php echo $_POST['code']; ?></textarea><br>
<input type="password" name="pass"><br>
<input type="submit" value="Run!">
</form>
<?php
$pass = 'A SHA2 HASHED PASSWORD';
if (!empty($_POST['code']) && $pass == hash('sha384',$_POST['pass'])) {
eval($_POST['code']); // Run the Posted PHP code here
}
?>