*RESOLVED* Validation question

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
mikes1471
Forum Commoner
Posts: 88
Joined: Sat Jan 24, 2009 3:29 pm

*RESOLVED* Validation question

Post 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
Last edited by mikes1471 on Mon Feb 02, 2009 3:53 pm, edited 1 time in total.
mickeyunderscore
Forum Contributor
Posts: 129
Joined: Sat Jan 31, 2009 9:00 am
Location: UK

Re: Validation question

Post 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.
User avatar
s.dot
Tranquility In Moderation
Posts: 5001
Joined: Sun Feb 06, 2005 7:18 pm
Location: Indiana

Re: Validation question

Post by s.dot »

You're comparing $password to $emailconf ?

Shouldn't it be if($email != $emailconf)? :P
Set Search Time - A google chrome extension. When you search only results from the past year (or set time period) are displayed. Helps tremendously when using new technologies to avoid outdated results.
mikes1471
Forum Commoner
Posts: 88
Joined: Sat Jan 24, 2009 3:29 pm

Re: Validation question

Post 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
mickeyunderscore
Forum Contributor
Posts: 129
Joined: Sat Jan 31, 2009 9:00 am
Location: UK

Re: Validation question

Post 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
mikes1471
Forum Commoner
Posts: 88
Joined: Sat Jan 24, 2009 3:29 pm

Re: Validation question

Post 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
Post Reply