I have a form and fields are Name, Email, Password. Client-side validation is working perfectly. I am working on server-side validation.
I am getting the issue on else part. For testing, I added echo $email
and I am getting the email id. Now that email id will check in the database is exists or not. If exist the display the error if not existing the display the not exist.
if(condition){}
elseif(condition){}
elseif(condition){}
elseif(condition){}
else{
echo $email; // here I am able to display the email id
$sql_check_email="SELECT email FROM register WHERE email =?";
$stmt = $conn->prepare($sql_check_email);
$stmt->bind_param("s", $email);
$stmt->execute();
$stmt->bind_result($email);
$rows = $stmt->fetch();
$total_rows = count($rows);
if( $total_rows > 0 ){
$_SESSION['email_error']= 'This email is alredy register with us';
header('location:register');
}else{
echo $email;// why my email id not displaying here?
echo $name;
echo $password;
echo $date_of_added;
echo"Not exist";
}