Jump to content

[SOLVED] Why isn't this simple script working?


sh0wtym3

Recommended Posts

I wanted to make the username case sensitive on my log-in page, so I made the script below.

 

But it redirects to http://mysite.com/login.php?cmd=nouser even if the username is typed correctly (in proper case)..?

 

Thanks in advance.

 

$check = mysql_query("SELECT username FROM users WHERE username = '".$_POST['username']."'")or die(mysql_error());

 

if(strcmp($_POST['username'], $check) != 0) {

header("Location: http://mysite.com/login.php?cmd=nouser");

die('');

}

I wanted to make the username case sensitive on my log-in page, so I made the script below.

 

But it redirects to http://mysite.com/login.php?cmd=nouser even if the username is typed correctly (in proper case)..?

 

Thanks in advance.

 

$check = mysql_query("SELECT username FROM users WHERE username = '".$_POST['username']."'")or die(mysql_error());

 

if(strcmp($_POST['username'], $check) != 0) {

header("Location: http://mysite.com/login.php?cmd=nouser");

die('');

}

 

You need to fetch the row after running the query

 

$row = mysql_fetch_assoc($check);

if(strcmp($_POST['username'], $row['username']) != 0) {

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.