Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

use post to check 2 fields, 1 w/CONCAT

Status
Not open for further replies.

blasterstudios

Technical User
Dec 30, 2004
128
US
I'm trying to run a query to retrieve a username/password. I have two fields in my database. 1 is their free registered email with the site, and the other is an alternate email address. I need to use what is submitted in form as "email" to pull records out of the database if they match 1 of the 2 columns. What i have works for the alternate email (because it's stored as name@domain.com). I encounter a problem when it checks for the registered email because it's not stored as an email address, but just the first part (i.e. name without the @domain.com).

Here's what i've tried:
Code:
"SELECT
    userid,
    username,
    password,
    CONCAT(dfemail,'@dichiarafamily.com') AS dfemail,
    otheremail
FROM
    df_users
WHERE
    dfemail = '" . $_POST['email'] . "' OR
    otheremail = '" . $_POST['email'] . "'"
 
well crap, i guess i figured it out. i didn't know you could put the CONCAT in the WHERE part.

Code:
"SELECT
    userid,
    username,
    password,
    dfemail,
    otheremail
FROM
    df_users
WHERE
    CONCAT(dfemail,'@dichiarafamily.com') = '" . $_POST['email'] . "' OR
    otheremail = '" . $_POST['email'] . "'"
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top