Quantcast
Channel: DaniWeb Solved Topics
Viewing all articles
Browse latest Browse all 576

Check email if exist or not code is not working

$
0
0

How can i check if email exists i have this code but it is not working

<?php
include "Config.php";
function mksafe($data){
     $data=trim($data);
     $data=strip_tags($data);
     $data=htmlspecialchars($data);
     $data=addslashes( $data);
     return $data;
 }
  $fname = mksafe($_POST["fname"]);
  $lname = mksafe($_POST["lname"]);
  $email = mksafe($_POST["email"]);
  $sql = "SELECT * FROM `users` WHERE `email`=$email";
$result = $conn->query($sql);
if($result->num_rows >= 1) {
    echo "Email  already exist.";
} else {
 $sql = "INSERT INTO users (fname, lname, email,reg_date)
    values(' $fname', '$lname',' $email',now())";
     if ($conn->query($sql) === TRUE){ 
        header("Refresh:0; url=index.php");
       } else { 
           echo "Error: " . $sql . "<br>" . $conn->error; 
           } 

}

 $conn->close();

Viewing all articles
Browse latest Browse all 576