我正在尝试使用php验证制作一个html表单,但尝试提交至少有一个填充文本字段的表单会说电子邮件不匹配(自制的部分代码不应该显示。
<?php
error_reporting(0);
if(isset($_POST["submit"])){
//File Verification
if(empty($_POST['username']) && empty($_POST['password1']) && empty($_POST['password2']) && empty($_POST['email1']) && empty($_POST['email2']) && empty($_POST['bday'])){
echo"Kom op, vul alles in";
echo "<meta http-equiv='refresh' content='5;URL=register.php' />";
exit();
}
else{
$email1 = $_POST['email1'];
$email2 = $_POST['email2'];
$pass1 = $_POST['password1'];
$pass2 = $_POST['password2'];
if(email1 == email2){
if(pass1 == pass2){
}
else{
echo "<meta http-equiv='refresh' content='5;URL=register.php' />";
echo"Je wachtwoorden komen niet overeen";
exit();
}
}
else{
echo "<meta http-equiv='refresh' content='5;URL=register.php' />";
echo "Je email gegevens komen niet overeen";
exit();
}
}
}
else{
$form = <<<EOT
<form method="post" action="register.php">
Gebruikersnaam: <input type="text" name="username" placeholder="type hier je gebruikers naam"/><br /><br />
wachtwoord: <input type="password" name="password1" placeholder="type hier je wachtwoord"/><br /><br />
wachtwoord opnieuw: <input type="password" name="password2" placeholder="type je wachtwoord opnieuw in"/><br /><br />
email: <input type="text" name="email1" placeholder="type hier je email"/><br /><br />
email opnieuw: <input type="text" name="email2" placeholder="type hier je email opnieuw"/><br /><br />
Geboorte datum: <input type="date" name="bday"/ placeholder="type je geboorte datum hier"><br /><br />
<input type="submit" name="submit"/>
</form>
EOT;
echo $form;
}
?>
它只是显示
else{
echo "<meta http-equiv='refresh' content='5;URL=register.php' />";
echo "Je email gegevens komen niet overeen";
答案 0 :(得分:0)
尝试更改:
if(email1 == email2){
if(pass1 == pass2){
为:
if($email1 == $email2){
if($pass1 == $pass2){
答案 1 :(得分:0)
你有一个错字pass1 == pass2
。
此外,您可能想要更改:
if(empty($_POST['username']) &&...
到
if(empty($_POST['username']) OR...