我正在我的HTML FORM INPUT字段的php文件中创建验证函数。 如果没有正确填写,该函数应跳回到表单,如果填写正确,则跳转到新页面。 如何从表单发送信息而不必使用标题在URL中写入信息?
index.php中的表单:
<form method='post' action='validate.php'>
Name: <input type='text' name='name'>
Job: <input type='text' name='job'>
City: <input type='text' name='city'>
<input type='submit' value='Submit'>
</form>
Validate.php:
if (!empty($_REQUEST['name']) And (!empty($_REQUEST['job'])) And (!empty($_REQUEST['city']))){
$name = $_REQUEST['name'];
$job = $_REQUEST['job'];
$city = $_REQUEST['city'];
header("Location: go.php?name=$name&&job=$job&&city=$city");
}
else {
header("Location: index.php");
}
如果只有一个尚未填写的字段,我还希望跳回index.php以获取已填写的信息。
答案 0 :(得分:1)
你不应该那样做 不要跳到任何地方。
HTML标准要求每个表单值(以及textarea内容)使用htmlspecialchars()进行编码