我正在處理表單和表單處理程序。方法是_POST
,我使用PHP來處理它。現在,當我想要處理表格時,它說$username
是未定義的。使用POST處理表格
我的表格:
<html>
<head>
<title>Register</title>
<script type="text/javascript" src="includes/register_form_validator.js" ></script>
</head>
<body>
<form method="post" action="includes/register_form_handler.php" name="register_form" >
<label for="username" >Username :</label><input placeholder="username" type="text" /><br>
<label for="password">Password :</label><input type="password" name="password" /><br>
<label for="cpassword">Confirm Password :</label><input type="password" name="cpassword" /><br>
<label for="email">E-Mail :</label><input type="email" name="email" onChange="" /><br>
<input type="submit" value="Submit" />
</form>
</body>
</html>
處理程序:
<?php
// Do a Form Validation , Makes sure that resource is Valid///////////
$actual_link = "http://$_SERVER[HTTP_HOST]" . "/dcreview/register.php";
if (!isset($_SERVER['HTTP_REFERER'])) {
echo "Invalid Form";
exit;
} else {
if ($_SERVER['HTTP_REFERER'] != $actual_link) {
echo "Invalid Form";
exit;
}
}
///////////////////////////////////////////////////////////////////
// Processes Form //
$user = $_POST["username"];
$pass = $_POST['password'];
$email = $_POST['email'];
password_hash($pass, PASSWORD_BCRYPT);
?>
你的代碼似乎沒有提到'$ username',所以你的錯誤不匹配? –
'$ user'!='$ username'你的腳本定義了'$ user' –
感謝大家回答。我想我應該多看兩次我的代碼。這是我的眼睛的錯誤.sorry – GeekyMo