Posted inJavaScript / jQuery / Mysql / Mysqli / php

how to check email already exist in database in php? – 5 Ways To Check if Email already exists Using PHP

how to check email already exist in database in php: every user get the simple solution for the how to check if an email address already exists in the database in php?

how to check email already exist in database in php

Validate the email if already exists. The validation of email exist is a restriction to the user for duplicate remove or deleted.

5 Ways To Check if Email already exists Using PHP

Set Email Column as UNIQUE on the Database


Email:


Validate Email using MySQL SELECT query with WHERE clause

Example – how to check data already exist in database in php

 0){
    $email_error = "Sorry... email already taken";  
  }else{
    $query = mysqli_query($con, "INSERT INTO `members`(`email`) VALUES('$email')");
    echo 'Saved!';
  }
}

check username and email already exists

index.php


 0) {
        
        $row = mysqli_fetch_assoc($res);
        if($email==isset($row['email']))
        {
            	echo "email already exists";
        }
		if($membername==isset($row['membername']))
		{
			echo "Sorry, membername  already exists";
		}
		}
else{
	
//do your insert code here or do something (run your code)
}

?>

Don’t Miss : php check file exists

Check if username is already taken with PHP and MySQL

Create two files in your favorite text editor:

  1. register.php
  2. process.php
  3. styles.css

register.php:




  Register
  


  

Register

class="userfrm_err" >
class="userfrm_err" >
/body>

styles.css
Now the styles.css file:

#signup_frm h1 {
  text-align: center;
}
body {
  background: #A9D9C3;
}
#signup_frm {
  width: 37%;
  margin: 100px auto;
  padding-bottom: 30px;
  border: 1px solid #918274;
  border-radius: 5px;
  background: white;
}
#signup_frm input {
  width: 80%;
  height: 35px;
  margin: 5px 10%;
  font-size: 1.1em;
  padding: 4px;
  font-size: .9em;
}
.userfrm_err span {
  width: 80%;
  height: 35px;
  margin: 3px 10%;
  font-size: 1.1em;
  color: #D83D5A;
}
.userfrm_err input {
  border: 1px solid #D83D5A;
}
#reg_btn {
  height: 35px;
  width: 80%;
  margin: 5px 10%;
  color: white;
  background: #3B5998;
  border: none;
  border-radius: 5px;
}

process.php

 0) {
  	  $name_error = "Sorry... membername already taken"; 	
  	}else if(mysqli_num_rows($res_e) > 0){
  	  $email_error = "Sorry... email already taken"; 	
  	}else{
           $query = "INSERT INTO members (membername, email, password) 
      	    	  VALUES ('$membername', '$email', '".md5($password)."')";
           $results = mysqli_query($db, $query);
           echo 'Saved!';
           exit();
  	}
  }
?>

I hope you get an idea about how to check email already exist in database in php.
I would like to have feedback on my infinityknow.com blog.
Your valuable feedback, question, or comments about this article are always welcome.
If you enjoyed and liked this post, don’t forget to share.

I am Jaydeep Gondaliya , a software engineer, the founder and the person running Pakainfo. I'm a full-stack developer, entrepreneur and owner of Pakainfo.com. I live in India and I love to write tutorials and tips that can help to other artisan, a Passionate Blogger, who love to share the informative content on PHP, JavaScript, jQuery, Laravel, CodeIgniter, VueJS, AngularJS and Bootstrap from the early stage.

Leave a Reply

Your email address will not be published. Required fields are marked *

We accept paid guest Posting on our Site : Guest Post Chat with Us On Skype