darknessmdk Posted July 27, 2007 Share Posted July 27, 2007 Hi everyone, I have a need to make my login on my site case sensitive, can some one point me in the right direction? can't seem to find and solid leads Link to comment https://forums.phpfreaks.com/topic/62103-solved-making-a-field-case-sensitive/ Share on other sites More sharing options...
per1os Posted July 27, 2007 Share Posted July 27, 2007 Ummm....php is case sensitive. <?php $user = "MyName"; $input = "myname"; if ($input == $user) { echo 'Hello'; }else { echo 'Bad'; } $input = "MyName"; if ($input == $user) { echo 'Hello'; }else { echo 'Bad'; } ?> Should echo "BadHello" Link to comment https://forums.phpfreaks.com/topic/62103-solved-making-a-field-case-sensitive/#findComment-309208 Share on other sites More sharing options...
darknessmdk Posted July 27, 2007 Author Share Posted July 27, 2007 When I login to my site, I can use upper case or lower case and it accepts it. Maybe the mysql isnt case sensitive?? heres my code: <? session_start(); if(isset($_SESSION['uusername']) && isset($_SESSION['upassword'])) { $uusername = $_SESSION['uusername']; $upassword = $_SESSION['upassword']; } elseif (isset($_POST['uusername']) &&isset($_POST['upassword'])) { $uusername = $_POST['uusername']; $upassword = $_POST['upassword']; } else { //print("Username/Password not defined"); include("index.php"); exit(); } ?> <? include("database.php"); $result = mysql_query("SELECT * FROM uregister WHERE uusername = '$uusername' AND upassword = '$upassword'"); $countrows = mysql_num_rows($result); $row = mysql_fetch_array($result); if ($countrows >= 1) { $_SESSION['uusername'] = $uusername; $_SESSION['upassword'] = $upassword; $_SESSION['uid'] = $row['uid']; $_SESSION['names'] =$row['uusername']; $_SESSION['accounts'] = 'user'; $_SESSION['ids'] = $row['uid']; $ulastlogin = date("m/d/Y"); $uid = $_SESSION['uid']; $result = mysql_query("UPDATE uregister SET ulastlogin = '$ulastlogin' WHERE uid = $uid"); $_SESSION['ufirstname'] = $row['ufirstname']; include("uloginok.php"); exit(); } else { //print "Sorry, check your username/password."; include("index.php"); exit(); } mysql_close($linkID); ?> Link to comment https://forums.phpfreaks.com/topic/62103-solved-making-a-field-case-sensitive/#findComment-309211 Share on other sites More sharing options...
per1os Posted July 27, 2007 Share Posted July 27, 2007 $result = mysql_query("SELECT * FROM uregister WHERE uusername = '$uusername' AND upassword = '$upassword'"); $countrows = mysql_num_rows($result); $row = mysql_fetch_array($result); if ($countrows > 0 && $row['uusername'] != $uusername) { //print "Sorry, check your username/password."; include("index.php"); exit(); } PHP is case sensitive, mysql is case insensitive. Link to comment https://forums.phpfreaks.com/topic/62103-solved-making-a-field-case-sensitive/#findComment-309213 Share on other sites More sharing options...
darknessmdk Posted July 27, 2007 Author Share Posted July 27, 2007 Thats worked perfectly! thank you frost110 Link to comment https://forums.phpfreaks.com/topic/62103-solved-making-a-field-case-sensitive/#findComment-309226 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.