表单操作在提交时不重定向

时间:2016-11-09 21:05:53

标签: php html

仍然是php的新手,但我无法弄清楚我的表单出错了。当我点击提交时,它不会重定向到我的PHP脚本。所有文件都在同一个文件夹中

reservations.html

<html>
<body>
   <h1>Reservations</h1>
   <form action="reservations.php" method="POST">
       <input id="city" name='city' type="text" placeholder="Airport Code or City"><br>
       <input id='submit' name='submit' type="button" value="Submit">
   </form>
</body>
</html>

reservations.php

<?php
   $city = $_POST['city'];
   if (isset($_POST['submit'])){
       print "<h1>$city</h1>";
   }
?>

也许我误解了它是如何工作的但我认为它会将url更改为server_url / reservations.php并显示我在文本框中输入的内容。

1 个答案:

答案 0 :(得分:7)

您的提交按钮必须{i}}提交才能自动重定向。

type
相关问题