Return to Snippet

Revision: 52152
at October 14, 2011 19:22 by smoothdzion


Initial Code
// PHP Code
<?php
	//MySQL class: http://mbe.ro/2009/08/30/fast-and-easy-php-mysql-class/
	require('../shared/db-class.php');
	$email = $_REQUEST["email_address"];
	//$email = '[email protected]'; // Just for testing.
	$validate = new mysql();
	$checkemail = $validate->query("SELECT * FROM users WHERE email_address = '$email'");
	if (count($checkemail) == 1){
	    $valid = "false";
	} else {
	    $valid = "true";
	}
	echo $valid;
?>

// jQuery
// FORM VALIDATION
	$('#form').validate({
		rules:{
			first_name: "required",
			last_name: "required",
			email_address: {
				required: true,
				email: true,
				remote: "email-check.php"
			}
		},messages:{
			email_address: {
				remote: jQuery.format("{0} is already in use!")
			}
		}
		
	});

Initial URL

                                

Initial Description
Just some common code I wanted to put up somewhere that can be used to check for unique email address in database for form registration.

Initial Title
jQuery Server Side Validation - Check for Unique Email Address

Initial Tags

                                

Initial Language
jQuery