我衷心问候我需要在单击提交按钮后保留文本框中的值,如果发现错误。基本上我想要的东西,如果用户将任何字段留空并按下保存按钮,则会弹出错误消息并且不刷新页面,它会将用户带回表单,他只需填写留空的字段...下面是我的代码
<html>
<form method="post" action="">
Enter Name : <input type="text" name="name" /><br/>
Enter Password : <input type="password" name="pass" /><br/>
<input type="submit" name="save" value="Save" />
</form>
</html>
php code
<?php
if (isset($_POST["save"]))
{
$name = $_POST["name"];
$pass = $_POST["pass"];
if (($name == '') && ($pass == ''))
{
echo "Fields Must Be Filled...";
exit();
}
if ($name == '') {
echo "Enter Name...";
exit();
}
if ($pass == '') {
echo "Enter Password...";
exit();
}
else
{
echo "Your name " . $name;
echo "<br/>";
echo "Your Password " . $pass;
}
}
?>