每当我在表单中提交内容时,我都想检查是否有任何字段为空。到目前为止,我没有工作
$firstname = $_POST['firstname'];
$lastname = $_POST['lastname'];
$username = $_POST['username'];
$password = $_POST['password'];
$passwordconf = $_POST['passwordconf'];
$email = $_POST['email'];
$securityq = $_POST['securityq'];
$qanswer = $_POST['qanswer'];
if(empty($firstname) || empty($lastname) || empty($username) || empty($password) || empty($passwordconf) || empty($email) || empty($securityq) || empty($qanswer))
{
echo "You did not fill out the required fields.";
}
和表格
<form name="registrationform" action="register.php">
First Name:<input type="text" name="firstname">
Last Name:<input type="text" name="lastname">
Email:<input type="text" name="email">
Username:<input type="text" name="username">
Password:<input type="password" name="password">
Confirm Password:<input type="password" name="passwordconf">
Security Question:<input type="text" name="securityq">
Answer:<input type="text" name="qanswer">
<input type="submit" name="submit" value="Register">
</form>
如果有帮助,这里是注册页面http://www.myjournal.tk/register.html