0

I have been busy for such a long time now to get my registeration form to check if the mail is valid beforehand I have to submit the form. I've seen countless tutorials, but I could not get this done without having the need of sumbit.

Note that I am very new to web development, so be patient with me :) Off I go:

In my jquery validation form i have the following statement:

$(document).ready(function() {

$("#registerform").validate( {
    rules: {
        NAMEEMAIL: {
            required: true,
            email: true,
            remote: 'register.php'
            }
    },
    messages: {
        NAMEEMAIL: {
            required: 'Voer uw e-mail adres in.',
            email: 'Voer een geldige e-mail adres in.',
            remote: 'E-mail is bezet Kies een andere e-mail adres.'
        }
});
});

In my html form i have the following

<form id="registerform" role="form" action='register.php' method='POST'>
<input type="text" name="NAMEEMAIL" id="NAMEEMAIL" type="email"/>
</form>

and my PHP as following (html and php are in the same file and is called register.php)

$emailget = trim($_GET['NAMEEMAIL']);
$emailquery = "SELECT DATABASEEMAIL FROM DATABASETABLE WHERE DATABASEEMAIL='$emailget'";
$emailresult = $databaseconnection->query($emailquery);
if($emailresult->num_rows == 0) 
{
    echo 'true';
}
else
{
    echo 'false';
}

Please note that database connection etc. is on another page, but the link works. Email shows true, which mean address is unique and false when it already exists in the database. This only occurs when I submit the form though and not while typing or when i get out of focus from the field, like i saw on the tutorials. The validation form works too, when field is left blank it gives error message or when it is not a valid email field, but that remote error doesn't show up at all.

What masterpiece am I missing here? Or am I doing something wrong here> Any help would be very nice. I would like to thank you in advance.

Update1: Try registering at google, when you fill in the email part it will let you immediately know that the email is occupied or available.

Misseria
  • 1
  • 1

0 Answers0