/ Published in: jQuery

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.
Expand |
Embed | Plain Text
Copy this code and paste it in your HTML
// 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 = 'test@gmail.com'; // 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!") } } });
Comments
