PDA

View Full Version : can someone take a look and tell me why - please !


vosgien
07-09-2003, 05:59 PM
Hi,
This is the code in my php file

$query = "SELECT entryID,paid,password,email FROM $table WHERE email='$mail'";
$result=mysql_query($query);
if($row = mysql_fetch_assoc($result))
{
$newID = $row['entryID'];
$pass = $row['password'];
$Newmail = $row['email'];
$newPaid = $row['paid'];
if($newID != $ID || $pass != $pword || $Newmail != $mail)
{
print "&_root.Status=".("couldn't find your registration")."&";
exit;
}
else
{
print "&_root.Status=".("your ID number is $newID");
}
}

When at the flash site I enter an incorrect ID number or anincorrect password the code kicks me out - just like it should, however, when I enter an incorrect email address, nothing happens !
I have double checked my variable names in Flash and they are all OK, there doesn't seem to be a syntax error in the above ( makes a change), and of course if I enter all the correct details it works like a charm - its just the email thing that is not working
Can someone have a peek and tell me why ?

Cheers

Vosgien

tg
07-09-2003, 07:35 PM
is your 'else' statement supposed to be associated with your first 'if' statement or your second, cause right now it is connected to the second (nested inside the first)... so if your first if statement returns false (no records), then nothing is set up to happen, cause there is no else statement to fall back on.

vosgien
07-09-2003, 07:40 PM
Hi tg,
No, the code works the way I want it to except for the email check

I enter an incorrect ID number or an incorrect password the code kicks me out - just like it should, however, when I enter an incorrect email address, nothing happens !

as the password and ID checks work and I cannot figure out why !

Vosgien

tg
07-09-2003, 07:43 PM
i guess i dont understand how your passing in an incorrect email address...

if you send in an email, password, and username, your sql goes out and gets the user name/password that matches the email you sent in... so either, the name password will/will not match, or the email address will not be found thus returning a blank recordset.

???

tg
07-09-2003, 07:47 PM
... let me try to illustrate to help clearify what im saying so that maybe you can clear up my misunderstanding...


if my db looks like:

bob:pass1:bob@tg.net
sam:pass2:sam@tg.net
joe:pass3:joe@tg.net


then in my code i pass to your script:
tom:xxx:bob@tg.net

the sql will return bob:pass1:bob@tg.net
the script will say name/pass don't match

if i pass in
bob:pass1:toto@tg.net

the sql won't return anything, cause no records were found.


if i pass in the correct username/password but incorrect email:
bob:pass1:sam@tg.net

the sql will return sam:pass2:sam@tg.net, so you get the message that the username/password don't match... cause your comparing it to criteria based on the email.

vosgien
07-09-2003, 08:10 PM
Sooooo......... I need to validate the email before pulling out the rest of the info with something like

$query = "SELECT entryID,paid,password,email FROM $table WHERE email='$mail'";
$result=mysql_query($query);
if(!result)
{
print "&_root.Status=".("tell user to politely go away")"&";
exit
}
else if($row = mysql_fetch_assoc($result))
{
$newID = $row['entryID'];
$pass = $row['password'];
$Newmail = $row['email'];
$newPaid = $row['paid'];
}
if($newID != $ID || $pass != $pword )
{
print "&_root.Status=".("couldn't find your registration")."&";
exit;
}
else
{
print "&_root.Status=".("your ID number is $newID");
}

I'm not sure about the braces or the layout here, but is that what you mean ?

Vosgien

tg
07-09-2003, 08:38 PM
well, considering i don't know php, so i don't know what some of your function calls return, i guess my only consern would be your elseIf statement



else_if($row_=_mysql_fetch_assoc($result))_
//if this returns false, then none of your variables are initialized...
{_

$newID_=_$row['entryID'];

$pass_=_$row['password'];

$Newmail_=_$row['email'];

$newPaid_=_$row['paid'];

}
/*
so if non of your variables are initialized, then will the next if statement work?....
my guess is that your elseif will always be true, because of your initial if statment.
but like is said, i dont really know php...
*/

if($newID_!=_$ID_||_$pass_!=_$pword_)

{

_print_"&_root.Status=".("couldn't find your registration")."&";_

exit;

}



hope this helps for you... or someone who knows what the hell their talking about (not me) comes along to help you out with the php part of this.



in the end, i always try to set my scripts up to catch any 'possible' errors and return some sort of information (error or data) back to flash, so it can handle the error and inform the user.

vosgien
07-09-2003, 08:45 PM
Hi,
No, you have been a big help tg, I am also learning PHP, slowly it is coming together and dialogues like this just open up more doors.
The else if statement is a typo and round the wrong way, not convinced that is the way to go, just need to tell the user to b***** off if he is trying to get in without paying.

I'm nearly there ( with this one) and I am just about done for tonight !

Cheers

Vosgien