Re: Email verification
| From: | Cesar Aracena | Date: | Wed, 31 Dec 2003 18:38:23 +0000 |
| Subject: | Re: Email verification | ||
| References: | 1 2 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-173571@lists.php.net to get a copy of this message | ||
Well Brad... it worked. Guess I forgot to use well the IF statements.
Thanks.
"Brad Pauly" <brad@robinsontech.com> escribió en el mensaje
news:1072895954.2848.146.camel@earth...
> On Wed, 2003-12-31 at 11:18, Cesar Aracena wrote:
> > Hi all,
> >
> > I'm trying to create a script to check for errors in submitted forms. I
want
> > the visitor to enter two times the email address and then check for
it...
> > This is what I have so far. The scripts checks if the email was entered
in
> > both fields, but not if they are equal to each other... ???
> >
> > if (!trim($email1))
> > {
> > echo "<BR>El <B>E-mail</B> es requerido.";
> > $errors++;
> > if (!trim($email2))
> > {
> > echo "<BR>El <B>E-mail</B> es requerido en ambos
> > campos.";
> > $errors++;
> > if ($email1 != $email2)
> > {
> > echo "<BR>Las <B>direcciones de E-mail</B> no
> > concuerdan.";
> > $errors++;
> > }
> > }
> > }
> >
> > What is wrong? Thanks in advanced and happy new year to all.
>
> The check to see if they are the same needs to be outside of the checks
> for being blank. If they are both not blank, you will never get to the
> last check. You could check for both in the first if, then do the
> comparison. Something like (untested):
>
> if (!trim($email1) || !trim($email2)) {
> echo "<BR>El <B>E-mail</B> es requerido en ambos campos.";
> $errors++;
> } elseif ($email1 != $email2) {
> echo "<BR>Las <B>direcciones de E-mail</B> no concuerdan.";
> $errors++;
> }
>
> - Brad