[英]Using header in PHP with hidden input fields
我正在為我的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來填充已經填寫的信息,如果它只是一個尚未填寫的字段。
你不應該那樣做。
不要跳到任何地方。
HTML標准要求每個表單值(以及textarea內容)都必須使用htmlspecialchars()進行編碼
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.