sh0wtym3 Posted October 11, 2008 Share Posted October 11, 2008 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(''); } Link to comment https://forums.phpfreaks.com/topic/128001-solved-why-isnt-this-simple-script-working/ Share on other sites More sharing options...
Prismatic Posted October 11, 2008 Share Posted October 11, 2008 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) { Link to comment https://forums.phpfreaks.com/topic/128001-solved-why-isnt-this-simple-script-working/#findComment-662819 Share on other sites More sharing options...
sh0wtym3 Posted October 11, 2008 Author Share Posted October 11, 2008 Thanks, it works now. Link to comment https://forums.phpfreaks.com/topic/128001-solved-why-isnt-this-simple-script-working/#findComment-662930 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.