我真的以为我把这个放下了,但由于某种原因,在回声中,它并不想执行命令。它只是回应网页网址。
http://localhost/<?php echo htmlentities($_SERVER[\'PHP_SELF\']); ?>
<?php
echo' <form name="action" action="<?php echo htmlentities($_SERVER[\'PHP_SELF\']); ?>" method="post">
<input type="text" name="name"><br>
<input type="submit" name="submit" value="Submit Form"><br>
</form>';
?>
我打算尝试将其发布到自己,然后如果有帖子数据那么:
if($_SERVER['REQUEST_METHOD'] == 'POST' && isset($_POST['action'])){
//do something here
}
我也试图打破回声:
echo " <form name='action' action=".<?php echo htmlentities($_SERVER['PHP_SELF']); ?>." method="post">
<input type='text' name='name'><br>
<input type='submit' name='submit' value='Submit Form'><br>
</form>";
答案 0 :(得分:0)
你不能在另一个php / echo语句中做一个echo语句。如果你已经脱离了php,你应该这样做:
echo " <form name='action' action=".htmlentities($_SERVER['PHP_SELF'])." method="post">
<input type='text' name='name'><br>
<input type='submit' name='submit' value='Submit Form'><br>
</form>";
或PHP之外:
?>
<form name='action' action="<?php echo htmlentities($_SERVER['PHP_SELF']); ?>" method="post">
<input type='text' name='name'><br>
<input type='submit' name='submit' value='Submit Form'><br>
</form>
<?php