Jump to content

login username issue


Smudly

Recommended Posts

If a username registers, their username's first letter is automatically capitalized and sent to the database. If a user decides to capitalize a second letter in the middle of their username (Ex: McLoven), unless the username is typed with that capitalized letter, I get an error that says "Incorrect Password!". The password is set as an MD5 encryption.

 

Any suggestions on what to do to fix this problem?

 

MySql version: 5.0.91

 

Here's my Login.php

 

<?php
$username = ucfirst($_POST['username']);
$password = $_POST['password'];


include('inc/connect.php');
if ($username&&$password)
{

$query = mysql_query("SELECT * FROM users WHERE username='$username'");

$numrows = mysql_num_rows($query);

if ($numrows!=0)
{

while ($row = mysql_fetch_assoc($query))
{
       $dbusername = $row['username'];
       $dbpassword = $row['password'];
       $userid = $row['id'];



// $_SESSION['username'] = $username;
// $_SESSION['userid'] = $userid;
}

// check to see if they match
if ($username==$dbusername&&md5($password)==$dbpassword)
{
  //echo "You're In! <a href='member.php'>Click</a> here to enter the member page.";
  session_start();
  $_SESSION['username']=$username;
  $_SESSION['views'] = 0;
  header('Location:http://www.daobux.com/member.php');
}
else
    echo "Incorrect Password!";

}
else
    die("That user doesn't exist!");


}
else
    die("Please fill out all fields!");


?>

Link to comment
https://forums.phpfreaks.com/topic/205118-login-username-issue/
Share on other sites

You're getting the username error because of the conditional; if either part of the conditional fails, the error message "Incorrect Password" is echoed.

if ($username==$dbusername&&md5($password)==$dbpassword)

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.