В настоящее время я тестирую свое приложение в проекте, над которым я работаю. Я удивлен, увидев, что FILTER_VALIDATE_EMAIL сообщает мне, что мой адрес электронной почты 'kwasikm@yahoo.co.uk' недействителен. Где-то должно быть что-то спрятано. Я надеюсь, что кто-то может мне помочь. Как показано ниже
<?php
if(isset($_POST['register-submit'])){
require 'dbh.inc.php';
$fullname = $_POST['fullname'];
$emailaddress = $_POST['emailaddress'];
$username = $_POST['username'];
$password = $_POST['password'];
$passwordAgain = $_POST['passwordAgain'];
$usersEmailcode = password_hash($username,PASSWORD_DEFAULT + microtime());
if(empty($fullname)){
header("Location: ../register.php?error=emptyname");
exit();
}else if(!preg_match("/^[a-zA-Z ]*$/",$fullname)){
header("Location: ../register.php?error=onlyLetters");
exit();
}
if(empty($emailaddress)){
header("Location: ../register.php?error=emailEmpty");
exit();
//email validation . problem here
}else if(!filter_var($emailaddress,FILTER_VALIDATE_EMAIL));
header("Location: ../register.php?error=invalidEmail");
exit();
if(empty($username)){
header("Location: ../register.php?error=usernameEmpty");
exit();
}else if(strlen($username)<5){
header("Location: ../register.php?error=usernameShort");
exit();
}else if(!preg_match("/^[a-zA-Z0-9]*$/",$username)){
header("Location: ../register.php?error=onlyNumAndLetters");
exit();
}
if(empty($password)){
header("Location: ../register.php?error=pwdEmpty");
exit();
}else if(strlen($password)<6){
header("Location: ../register.php?error=pwdShort");
exit();
}else if(!preg_match("#[0-9]+#",$password)){
header("Location: ../register.php?error=oneNumberAtLeast");
exit();
}else if(!preg_match("#[A-Z]+#",$password)){
header("Location: ../register.php?error=upperCase");
exit();
}else if(!preg_match("#[\W]+#",$password)){
header("Location: ../register.php?error=specialChar");
exit();
}
if(empty($passwordAgain)){
header("Location: ../register.php?error=pwdAgainEmpty");
exit();
}else if($passwordAgain !== $password){
header("Location: ../register.php?error=noMatch");
exit();
}
$sql = "SELECT usersEmail,usersUsername FROM users WHERE usersEmail=? AND usersUsername=?";
$stmt = mysqli_stmt_init($conn);
if(!mysqli_stmt_prepare($stmt,$sql)){
header("Location: ../register.php?error=sqlError");
exit();
}else{
mysqli_stmt_bind_param($stmt,"ss",$emailaddress,$username);
mysqli_stmt_execute($stmt);
$result = mysqli_stmt_store_result($stmt);
$resultCheck = mysqli_stmt_num_rows($result);
if($resultCheck > 0){
header("Location: ../regsiter.php?error=userTaken");
exit();
}else{
$sql = "INSERT INTO
users(usersName,userEmail,usersUsername,usersPassword,usersEmailcode)
VALUES(?,?,?,?,?)";
$stmt = mysqli_stmt_init($conn);
if(!mysqli_stmt_prepare($stmt)){
header("Location: ../regsiter.php?error=sqlError");
exit();
}else{
$pwdHashed = PASSWORD_HASH($password,PASSWORD_DEFAULT);
mysqli_stmt_bind_param($stmt,"sssss",$fullname,$emailaddress,$username,$pwdHashed,$usersEmailCode);
mysqli_stmt_execute($stmt);
//send account activation email
$to = $email;
$url = "http://marksmandigital.net/activate.php?email=".$emailaddress ."&usersEmailcode=".$usersEmailcode;
$from = "info@marksmandigital.net";
$subject = 'Activate your Account!';
$message ='<p>Click the link below to verify your account!</p>';
$message .= '<p><a href="'.$url.'">"'.$url.'"</a></p>';
$headers = "From: Marksman <info@marksmandigital.net>\r\n";
$headers .= "Reply-To:info@marksmandigital.net\r\n";
$headers .= "Content-type:text/html\r\n";
mail($to,$subject,$message,$headers);
header("Location: ../register.php?register=success");
exit();
}
}
}
mysqli_stmt_close($stmt);
mysqli_close($conn);
}else{
header('Location: ../register.php');
exit();
}
Есть ли способ обойти это /. html форма здесь
<form method="post" action="includes/register.inc.php" class="form">
<div class="form-row">
<div class="form-group col-md-12">
<input type="text" name="fullname" class="form-control" placeholder="Enter Your Full Name">
</div>
</div>
<div class="form-row">
<div class="form-group col-md-12">
<input type="text" name="emailaddress" class="form-control" placeholder="Your Email Address">
</div>
</div>
<div class="form-row">
<div class="form-group col-md-12">
<input type="text" name="username" class="form-control" placeholder="Choose A Username">
</div>
</div>
<div class="form-row">
<div class="form-group col-md-12">
<input type="password" name="password" class="form-control" placeholder="Choose A Password">
</div>
</div>
<div class="form-row">
<div class="form-group col-md-12">
<input type="password" name="passwordAgain" class="form-control" placeholder="Repeat Your Password">
</div>
</div>
<div class="form-row">
<div class="form-group col-md-12">
<input type="submit" name="register-submit" class="form-control btn btn-success" value="SUBMIT REGISTRATION">
</div>
</div>
</form>