Tycoon Talk
Become a Big fish!
The number 1 forum for online business!
Post topics, ask questions, share your knowledge.
Tycoon Talk is part of Freelancer.com - find skilled workers online at a fraction of the cost.

PHP Forum


You are currently viewing our PHP Forum as a guest. Please register to participate.
Login



Freelance Jobs

Reply
Old 06-17-2010, 08:02 PM login username issue
Skilled Talker

Posts: 83
Trades: 0
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 Code:
<?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!");


?>
Smudly is offline
Reply With Quote
View Public Profile
 
 
Register now for full access!
Old 06-17-2010, 10:43 PM Re: login username issue
mgraphic's Avatar
Truth Seeker

Latest Blog Post:
JAMISONTUNES
Posts: 2,918
Name: Keith Marshall
Location: Connecticut
Trades: 0
You can use an alternative case-insensitive search with the LIKE keyword:

SELECT * FROM users WHERE username LIKE '$username'
__________________

<mgraphic /> - I don't have a solution but I admire the problem.
mgraphic is offline
Reply With Quote
View Public Profile
 
Old 06-18-2010, 04:25 AM Re: login username issue
Novice Talker

Posts: 5
Trades: 0
thanks for the informations
yaneparser is offline
Reply With Quote
View Public Profile
 
Old 06-18-2010, 05:44 AM Re: login username issue
tripy's Avatar
Do not try this at home!

Posts: 3,621
Name: Thierry
Location: I'm the uber Spaminator !
Trades: 0
Quote:
You can use an alternative case-insensitive search with the LIKE keyword:

SELECT * FROM users WHERE username LIKE '$username'
That, or force a lower case compare:
Code:
SELECT * FROM users WHERE lower(username) = lower('$username')
__________________
Only a biker knows why a dog sticks his head out the window.
tripy is offline
Reply With Quote
View Public Profile Visit tripy's homepage!
 
Old 06-18-2010, 01:25 PM Re: login username issue
BmPotts's Avatar
Novice Talker

Posts: 4
Name: Billy Potts
Location: Telford, UK
Trades: 0
PHP Code:
<?php

session_start
();

include(
'inc/connect.php');

$username ucfirst($_POST['username']);
$password md5($_POST['password']);


if (
$username == !"" && $_POST['password'] == !"")
{

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

$numrows mysql_num_rows($query);

if (
$numrows != 0)
{

       
$row mysql_fetch_array($query);
 
       
$dbusername $row['username'];
       
$dbpassword $row['password'];
       
$userid     $row['id'];


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

} else {
    die(
"Invalid user");
}

} else {
    echo(
"all fields!");
}

?>
__________________

Please login or register to view this content. Registration is FREE
- A Social Network & Community System like no other!
BmPotts is offline
Reply With Quote
View Public Profile Visit BmPotts's homepage!
 
Reply     « Reply to login username issue
 

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off





   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML



Page generated in 0.16053 seconds with 12 queries