表单动作在提交时没有重定向


form action not redirecting when submitted

仍然是新的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并显示我在文本框中输入的任何内容

您的提交按钮必须为type提交,以便自动重定向。

<input id="submit" name="submit" type="submit" value="Submit">