Jump to content


Photo

2 fields dont match but both are in DB, what do i do?


  • Please log in to reply
1 reply to this topic

#1 eastcoastdubs

eastcoastdubs
  • Members
  • Pip
  • Newbie
  • 4 posts
  • LocationAllentown, PA

Posted 16 February 2003 - 07:15 AM

I have a userid and email field and I have a function checking if both are in the database first and to give the correct error message if they are not. BUT hypothetically speaking. Say someone putd a username and email address that are both in the database BUT they are not in the same record. I tried doing this and I got a blank screen. The query goes thru correctly since the error messages I have just check to see if they are in the database. BUT there is no error stoping saying they are not in the same record since the email and userid do not match.

Should I use a third function checking both field and saying that the combination email and userid do not match?

I use this to get the fields for my mail() function

$sql = \"SELECT userid, userpassword, username, useremail FROM $user_tablename WHERE userid = \'$userid\' AND useremail = \'$email\'\";
eastcoastdubs.com - the next generation of volkswagen enthusiasts

#2 pallevillesen

pallevillesen
  • Members
  • PipPipPip
  • Advanced Member
  • 135 posts
  • LocationDenmark

Posted 17 February 2003 - 09:39 AM

$sql = \"SELECT userid, userpassword, username, useremail FROM $user_tablename WHERE userid = \'$userid\' OR useremail = \'$email\'\";

If you get 1 row - same person
2 rows - userid allready taken, email allready taken - by different persons.
This is only valid IF you check for a unique userid, i.e. that you don\'t allow two persons to have the same userid (which I assume you do).

Reading your post again, I think you want to check that a given userid and email match the SAME RECORD ?

Then your original solution is the correct one:
$sql = \"SELECT userid, userpassword, username, useremail FROM $user_tablename WHERE userid = \'$userid\' AND useremail = \'$email\'\";

This returns only one row, if the submitted userid and email are in the same record, if NOT it will return zero rows!

P.
Palle Villesen, www.birc.dk [br]Bioinformatics Research Center




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users