jQuery AJAX Live Check Email Availability using PHP MySQLi

jQuery AJAX Live Check Email Availability using PHP MySQLi

In this Post We Will Explain About is jQuery AJAX Live Check Email Availability using PHP MySQLi With Example and Demo.Welcome on Live24u.com – Examples, The best For Learn web development Tutorials,Demo with Example! Hi Dear Friends here u can know to check email availability in php and mysql Example

In this post we will show you Best way to implement How to Check Email Availability using jQuery and PHP/MySQLi, hear for Live Email Availability Check using PHP and jQuery AJAX with Download .we will give you demo,Source Code and examples for implement Step By Step Good Luck!.

Also Read :   Check and Uncheck all Multiple Checkbox using jQuery




Creating Simple Database

You need be able to make a MySQL database named PHP live24u.

Creating our Form

And then, I make simple HTML form as well as input text for the main simple email address. Also, We have sd this available check emails in simple mysql database for simple main reference. make a new simple file, Like as PHP server side it as index.php as well as copy paste the source codes below.

<!DOCTYPE html>
<html>
<head>
	<meta charset="utf-8">
	<title>Live Email Availability Checking using PHP, jQuery and Ajax</title>
	<link rel="stylesheet" type="text/css" href="live24u/bootstrap/css/bootstrap.min.css">
</head>
<body>
<div class="live24u container">
	<h1 class="live24u page-header text-center">live email availability check using php and jquery ajax</h1>
	<div class="live24u row gst">
		<div class="gst col-sm-4 col-sm-offset-2 live24u">
			<div class="live form-group">
				<label>Email</label>
				<input type="text" class="live24u form-control gst" name="email" id="email">
				<span id="results" style="display:none;"></span>
			</div>
		</div>
		<div class="live24u col-sm-4">
			<table class="live24u table table-bordered">
				<thead>
					<th>Student Email</th>
				</thead>
				<tbody>
					<?php
					//Email Live Availability Check with PHP, Jquery & Ajax
						//db_conection
						$db_con = new mysqli('localhost', 'root', '', 'live24u');
 
						$liveQuery = "SELECT * FROM students";
						$query = $db_con->query($liveQuery);
 
						while($datarow = $query->fetch_assoc()){
							echo "
								<tr>
									<td>".$datarow['email']."</td>
								</tr>
							";
						}
					?>
				</tbody>
			</table>
		</div>
	</div>
</div>
<script src="live24u/jquery.min.js"></script>
<script type="text/javascript">
$(document).ready(function(){
	$('#email').keyup(function(e){
		e.preventDefault();
		var email = $(this).val();
		$.ajax({
			method: 'POST',
			url: 'db_check.php',
			data: {str_query: email},
			dataType: 'json',
			success: function(results){
				$('#results').show().html(results);
			}
		});
	});
});
</script>
</body>
</html>

Creating our Check Script

Last step, I make the source code that checks the PHP mysql database availability of the HTML Form inputted check email. Make a new simple main file, name it as Like as db_check.php as well as simple copy and paste the codes scipts.

Also Read :   authentication login with username or email in laravel

<?php
//check email availability in php and mysql
	//live initailize liveRes
	$liveRes = '';
 
	//db_conection
	$db_con = new mysqli('localhost', 'root', '', 'live24u');
 
	//input post
	$str_query = $_POST['str_query'];
 
	//PHP server side user email validation
	if (!filter_var($str_query, FILTER_VALIDATE_EMAIL)) {
	  $liveRes = 'Invalid email format'; 
	}
	else{
		//Simple here check if email exist
		$liveQuery = "SELECT * FROM students WHERE email = '$str_query'";
		$query = $db_con->query($liveQuery);
 
		if($query->num_rows > 0){
			$liveRes = 'Your Email already taken';
		}
		else{
			$liveRes = 'Your Email is free to use';
		}
	}
 
	echo json_encode($liveRes);
 
?>

You are Most welcome in my youtube Channel Please subscribe my channel. and give me FeedBack.
More Details……
Angularjs Example





Example

I hope you have Got What is Email Live Availability Check with PHP, Jquery & Ajax And how it works.I would Like to have FeedBack From My Blog(live24u.com) readers.Your Valuable FeedBack,Any Question,or any Comments about This Article(live24u.com) Are Most Always Welcome.