Jump to content

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


Recommended Posts

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\'\";

$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.

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.