我正在试验表格而且我无法说明为什么下面的鳕鱼不能回应出假设的结果。为什么我做错了,如何让它回应用户输入。
<?php
//way to tell if the form has been submitted (If form not submitted, display form again.)
if (!isset($_POST['submit'])){
?>
<form method="post" action="" />
<input type="text" name="city" />
<input type="submit">
</form>
<?php
//Process input
}
else
{
// Retrieve information from form submission.
$username = $_POST['city'];
echo "Your name is $username.";
}
?>
答案 0 :(得分:0)
为您的提交按钮添加名称属性:
//way to tell if the form has been submitted (If form not submitted, display form again.)
if (!isset($_POST['submit'])){
?>
<form method="post" action="" />
<input type="text" name="city" />
<input type="submit" name="submit">
</form>
<?php
//Process input
}
else
{
// Retrieve information from form submission.
$username = $_POST['city'];
echo "Your name is $username.";
}
?>