Jump to content

[SOLVED] QUERY HELP


Canman2005

Recommended Posts

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
Share on other sites

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
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

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