Page 1 of 1

*RESOLVED* Validation question

Posted: Mon Feb 02, 2009 3:05 pm
by mikes1471
Hi Guys

I'm no PHP expert and now I think I've reached my limit

I've made a registration form and I think the confirmation email field is causing me problems as I get the error message "Email address fields do not match!" upon form submission.

Well, the email addresses in 'email' and 'emailconf' do match so there must be a problem with the code, the text fields are here:

Code: Select all

echo "<tr><td>E-Mail</td><td><input type=\"text\" name=\"email\"></td></tr>\n";
    echo "<tr><td>Confirm E-Mail</td><td><input type=\"text\" name=\"emailconf\"></td></tr>\n";
My else statement is:

Code: Select all

$email2 = protect($_POST['emailconf']);

Code: Select all

if(!$email){
            $errors[] = "E-mail is not defined!";
        }
        if($password){
            if(!$emailconf){
                $errors[] = "Confirmation email is not defined!";
            }
        }
And the validation code is:

Code: Select all

if($email && $emailconf){
            if($password != $emailconf){
                $errors[] = "Email address fields do not match!";
            }
        }
Could someone please point out where I have gone wrong?

Mike

Re: Validation question

Posted: Mon Feb 02, 2009 3:10 pm
by mickeyunderscore
Your variable names seem a bit mixed up, because you assign the confirmation email to a variable called $email2, and then check a variable named $emailconf.

I don't see $email being assigned at all, and you also compare the $email2 variable to $password, not the other email.

Re: Validation question

Posted: Mon Feb 02, 2009 3:10 pm
by s.dot
You're comparing $password to $emailconf ?

Shouldn't it be if($email != $emailconf)? :P

Re: Validation question

Posted: Mon Feb 02, 2009 3:16 pm
by mikes1471
oh erm of course, just keeping you on your toes, as you were lol no, thanks, I copied the password validation script and pasted it to edit and use as email validation and must have forgotten, schoolboy error.

As for email2, words fail me. lol thanks again

Re: Validation question

Posted: Mon Feb 02, 2009 3:26 pm
by mickeyunderscore
Lol, the wonders of copy and paste. It's broken scripts for me a few times too, though you should see some of the messes I've got myself into using find and replace 8O

Re: Validation question

Posted: Mon Feb 02, 2009 3:38 pm
by mikes1471
Oh yeh I used find and replace aswell haha but anyway the registration form works great now thanks everyone who helped, I just need to create a string to make the three birth date fields enter a single database field in day/month/year format, fun! lol