Jump to content

Recommended Posts

Hi guys,

 

I am going nuts with this!

 

It HAS to be something dead simple but I can't seem to see what is staring me in the face.

 

Basically I have made a registration form and when complete you are emailed a link to click on.

When you click on the link you go to a new page. The page takes the email address and the verification code from the URL via _GET. The database is then queried for a match of the email address AND the verification code, if there is a relevant record then success is displayed otherwise unsuccessful is displayed.

 

Code:

$email = strip_tags(htmlentities($_GET['email']));
$code = strip_tags(htmlentities($_GET['code']));

// confirm the variables hold the correct data
echo "email: $email and code: $code";

$query = "SELECT * from userdb WHERE email='$email' AND code ='$code'";

if (mysql_query($query))
{	
echo	"success";
}
else
{
echo "unsuccessful";
}						

 

My problem is this query is always returning 'success'... even when the code and/or email does not match what is in my database?

 

What am i missing?

 

Thanks

Link to comment
https://forums.phpfreaks.com/topic/246194-going-insane-with-something-simple/
Share on other sites

if (mysql_query($query))

 

^^^ That's testing if the query executed without any ERRORS (i.e. a connection problem, a syntax error, a miss typed table/column name.)

 

That doesn't test if the query matched any rows or not. See - mysql_num_rows

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.