Jump to content

Case-sensitive Login Page. HELP!


SauloA

Recommended Posts

I've created a login page with the username and password fields but they are not case sensitive.  A user can enter their username and password in any fashion they want, all caps, all lower case, etc. and still achieve the same results to login in because the text fields or whatever are not case sensitive.  What can I do to achieve my desired results?

 

Here's to code for my entire login page.  I'd appreciate the help.

 

<?php require_once('../Connections/connBlog.php'); ?>

<?php

// *** Validate request to login to this site.

if (!isset($_SESSION)) {

 session_start();

}

 

$loginFormAction = $_SERVER['PHP_SELF'];

if (isset($_GET['accesscheck'])) {

 $_SESSION['PrevUrl'] = $_GET['accesscheck'];

}

 

if (isset($_POST['username'])) {

 $loginUsername=$_POST['username'];

 $password=$_POST['password'];

 $MM_fldUserAuthorization = "al_levelid";

 $MM_redirectLoginSuccess = "home.php";

 $MM_redirectLoginFailed = "failed.php";

 $MM_redirecttoReferrer = true;

 mysql_select_db($database_connBlog, $connBlog);

   

 $LoginRS__query=sprintf("SELECT user_id, user_sname, user_pass, al_levelid FROM user_tbl WHERE user_sname='%s' AND user_pass='%s'",

 get_magic_quotes_gpc() ? $loginUsername : addslashes($loginUsername), get_magic_quotes_gpc() ? $password : addslashes($password));

 

 $LoginRS = mysql_query($LoginRS__query, $connBlog) or die(mysql_error());

 $LoginArray= mysql_fetch_array($LoginRS); //Creates the array

 $loginFoundUser = mysql_num_rows($LoginRS);

 if ($loginFoundUser) {

   

   $loginStrGroup  = mysql_result($LoginRS,0,'al_levelid');

   

   //declare three session variables and assign them

   $_SESSION['MM_Username'] = $loginUsername;

  $_SESSION['MM_UserID'] = $LoginArray['user_id']; //Stores the user_id in a session variable.

  $_SESSION['MM_UserLevel'] = $LoginArray['al_levelid'];

   $_SESSION['MM_UserGroup'] = $loginStrGroup;        

 

   if (isset($_SESSION['PrevUrl']) && true) {

     $MM_redirectLoginSuccess = $_SESSION['PrevUrl'];  

   }

   header("Location: " . $MM_redirectLoginSuccess );

 }

 else {

   header("Location: ". $MM_redirectLoginFailed );

 }

}

?>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">

<head>

<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />

<title>Blog Login</title>

<link href="mystyles.css" rel="stylesheet" type="text/css" />

</head>

 

<body>

<form ACTION="<?php echo $loginFormAction; ?>" METHOD="POST" name="frmLogin" id="frmLogin">

 <table>

   <caption>

     Login to the site

   </caption>

   <tr>

     <th align="right" scope="row">Username:</th>

     <td><input name="username" type="text" id="username" size="10" maxlength="10" /></td>

   </tr>

   <tr>

     <th align="right" scope="row">Password:</th>

     <td><input name="password" type="password" id="password" size="10" maxlength="10" /></td>

   </tr>

   <tr>

     <th align="right" scope="row"> </th>

     <td><input type="submit" name="Submit" value="Login" /></td>

   </tr>

 </table>

</form>

</body>

</html>

Link to comment
https://forums.phpfreaks.com/topic/37565-case-sensitive-login-page-help/
Share on other sites

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.