Canman2005 Posted July 27, 2008 Share Posted July 27, 2008 Hi all I have this very simple login script // check login form has been POSTED if(isset($_POST['userlogin'])) { // check login details $total_query = "SELECT COUNT(*) as Num FROM `logins` WHERE username = '".$_POST['username']."' AND password = '".$_POST['password']."'"; $total_results = mysql_result(mysql_query($total_query),0); //check if user exists then login if($total_results == 1) { //query the database for full details $sql = "SELECT * FROM `logins` WHERE username = '".$_POST['username']."' AND password = '".$_POST['password']."'"; $query = @mysql_query($sql,$connection) or die(mysql_error()); while ($row = mysql_fetch_array($query)) { //create sessions session_register('loggedin'); //to confirm that the user has signed in $_SESSION['loggedin'] = 'testingsystem'; //create code to confirm user has logged in } print "<meta http-equiv=\"refresh\" content=\"0;URL=main.php\">"; exit(); } else { // wrong username and password print "<script>alert('Incorrect username\password combination.');</script>"; print "<meta http-equiv=\"refresh\" content=\"0;URL=index.php\">"; } } The problem is that I need to check the username and password are case sensetive, is there anyway I can do that? Thanks in advance Ed Link to comment https://forums.phpfreaks.com/topic/116843-solved-query-help/ Share on other sites More sharing options...
AndyB Posted July 27, 2008 Share Posted July 27, 2008 http://dev.mysql.com/doc/refman/5.0/en/charset-binary-op.html Link to comment https://forums.phpfreaks.com/topic/116843-solved-query-help/#findComment-600820 Share on other sites More sharing options...
Canman2005 Posted July 27, 2008 Author Share Posted July 27, 2008 Nice one Andy, cheers man Link to comment https://forums.phpfreaks.com/topic/116843-solved-query-help/#findComment-600821 Share on other sites More sharing options...
Nhoj Posted July 27, 2008 Share Posted July 27, 2008 You could also change the charset for the table in your MySQL databse to one that is case sensitive. Something like UTF8 should work. Most commonly the default is set to 'latin1_swedish_ci' which is case insensitive. Link to comment https://forums.phpfreaks.com/topic/116843-solved-query-help/#findComment-600824 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.