使用 PHP isset 进行条目检查后无输出
No output after entry check with PHP isset
我正在试验表格,我不知道为什么下面的 cod 不会回显假定的结果。为什么做错了以及如何让它回显用户输入。
<?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.";
}
?>
为您的提交按钮命名 属性:
//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.";
}
?>
我正在试验表格,我不知道为什么下面的 cod 不会回显假定的结果。为什么做错了以及如何让它回显用户输入。
<?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.";
}
?>
为您的提交按钮命名 属性:
//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.";
}
?>