compare multpile (optional) inputs against [solved]
Posted: Wed Sep 19, 2007 12:39 pm
Hello, I am trying to check submitted form data (cell phone, home phone, other phone) against the records in my DB to prevent duplicate records.
I am using these fields as one of several ways to identify a user that has already registered in the past.
But my code dictates that the user must fill out atleast one of these fields the other two can be left blank if so desired. The user can pick which of these fields they want to fill.
That leaves two of them possily empty.
If in my query I were to write the code
then every record without all three phone numbers will match any user who does not fill out all three fields.
Again, this query is to validate that the user has not previously registered, so it's obviously not going to work.
How can I check to make sure that every number entered into my DB is Unique.
In typing this question I think that I have thought of a solution. If it works I will post it, but also, I am a beginner and my hunch is that
this is a common issue and many of you may know a more standard and concise way of woring this out than what I am about to attempt.
Thanks
I am using these fields as one of several ways to identify a user that has already registered in the past.
But my code dictates that the user must fill out atleast one of these fields the other two can be left blank if so desired. The user can pick which of these fields they want to fill.
That leaves two of them possily empty.
If in my query I were to write the code
Code: Select all
$query0 = "SELECT
pid,
FROM
parent_info
WHERE
(street_address = '$street')
OR
(h_phone or c_phone or o_phone) = ('$h_phone' or '$c_phone' or '$o_phone')
OR
(email = '$email')" ;Again, this query is to validate that the user has not previously registered, so it's obviously not going to work.
How can I check to make sure that every number entered into my DB is Unique.
In typing this question I think that I have thought of a solution. If it works I will post it, but also, I am a beginner and my hunch is that
this is a common issue and many of you may know a more standard and concise way of woring this out than what I am about to attempt.
Thanks