Nov 24, 2015 03:12 PM
(This post was last modified: Nov 24, 2015 03:24 PM by Skidy.)
I can log in with info such as Ben:test however I can also log in with Ben:TEST. I have posted my login.php below. Why can people log in with their password in caps?
I also tried removing:
That has no effect on it.
EDIT: I fixed it using BINARY in my query. Why does this work?
The edit I made:
Code
<?php
session_start();
// Starting Session
$error='';
// Variable To Store Error Message
if (isset($_POST['submit'])) {
if (empty($_POST['username']) || empty($_POST['password'])) {
$error = "Username or Password empty";
echo $error;
//include('login_forms.html');
//header("location: login_retry.php?error=" . urlencode($error));
header("location: /ss/error/");
} else {
// Define $username and $password
$username=$_POST['username'];
//Check
$password=$_POST['password'];
// Establishing Connection with Server by passing server_name, user_id and password as a parameter
$connection = mysql_connect("localhost", "root", "");
// To protect MySQL injection for Security purpose
$username = stripslashes($username);
$password = stripslashes($password);
$username = mysql_real_escape_string($username);
$password = mysql_real_escape_string($password);
// Selecting Database
$db = mysql_select_db("test", $connection);
// SQL query to fetch information of registerd users and finds user match.
$query = mysql_query("select * from users where password='$password' AND username='$username'", $connection);
$rows = mysql_num_rows($query);
if ($rows == 1) {
$_SESSION['login_user']=$username;
// Initializing Session
#header("location: /ss/login/profile.php"); // Redirecting To Other Page
header("location: /ss/user/");
// Redirecting To Other Page
} else {
$error = "Username or Password is invalid";
echo $error;
//header("location: login_retry.php?error=" . urlencode($error));
header("location: /ss/error/");
}
mysql_close($connection);
// Closing Connection
}
}
?>I also tried removing:
Code
$username = stripslashes($username);
$password = stripslashes($password);
$username = mysql_real_escape_string($username);
$password = mysql_real_escape_string($password);That has no effect on it.
EDIT: I fixed it using BINARY in my query. Why does this work?
The edit I made:
Code
$query = mysql_query("select * from users where BINARY password = BINARY '$password' AND BINARY username= BINARY '$username'", $connection);


