Jump to content

[SOLVED] Making a field Case sensitive?


darknessmdk

Recommended Posts

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"

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);

?>

$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.

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.