Jump to content

Recommended Posts

Hi, For some reason every time I go to login with any password I can get through, so even if the password is not the one for my account I can still see the message "Login Succesful".

 

<?php

mysql_connect($db_host,$db_username,$db_password) or die(mysql_error());
mysql_select_db($db_database) or die(mysql_error());

$username = $_POST['username']; 
$password = $_POST['password'];
$secpass = md5("2392j3k2js21".$password.$username);

// Retrieve all the data from the "example" table
$result = mysql_query('SELECT * FROM owners WHERE username="$username"')
or die(mysql_error());  

// store the record of the table into $row
$row = mysql_fetch_array( $result );
// Print out the contents of the entry 
if ($row['password'] == $secpassword){

echo ("Login success!");

} else {

echo ("Login Error!");

}


?>

 

Cheers

Sean

Link to comment
https://forums.phpfreaks.com/topic/107217-solved-login-problem/
Share on other sites

Hi, For some reason every time I go to login with any password I can get through, so even if the password is not the one for my account I can still see the message "Login Succesful".

 

<?php

mysql_connect($db_host,$db_username,$db_password) or die(mysql_error());
mysql_select_db($db_database) or die(mysql_error());

$username = $_POST['username']; 
$password = $_POST['password'];
$secpass = md5("2392j3k2js21".$password.$username);

// Retrieve all the data from the "example" table
$result = mysql_query('SELECT * FROM owners WHERE username="$username"')
or die(mysql_error());  

// store the record of the table into $row
$row = mysql_fetch_array( $result );
// Print out the contents of the entry 
if ($secpass == $row['password']){

echo ("Login success!");

} else {

echo ("Login Error!");

}


?>

 

Does that work?

Link to comment
https://forums.phpfreaks.com/topic/107217-solved-login-problem/#findComment-549679
Share on other sites

well you got at least 2 problems that I see.  First off, $secpassword doesn't exist, so your condition looks like this: if ($row['password'] == NULL/FALSE) { ... } and since it seems to be coming out as true, $row['password'] is turning up FALSE if it's failing, or no result if nothing is returned from your query.

 

edit: Gah! multi-posts before I posted disregard this post.

Link to comment
https://forums.phpfreaks.com/topic/107217-solved-login-problem/#findComment-549682
Share on other sites

ok, well I have compared the real pass entered on the site with the one found in the database and they are different...

 

entered: 7674e5844a670dfcf2d067dd88b3****

found in database: 8b53602b51cbc88e7ce34****

 

As you can see they are differen, looks like we have found our problem, but now why, Here is my code fore my registration script as it may help:

 

http://pastebin.com/m6b3eda57

 

Cheers

Sean

Link to comment
https://forums.phpfreaks.com/topic/107217-solved-login-problem/#findComment-549707
Share on other sites

Edit: Need to check for changes before I post :)

 

Your newest problem comes from your hashing.

 

Check the page which makes the password, and make sure it has the same

$secpassword = md5("2392j3k2js21".$password.$username);

 

And just check that $username and $password are set properly in that file

 

Edit: still not watching

$securepass = md5("2392j3k2js21".$password.$username); matches, so that doesn't seem to be the problem :(

 

I'd suggest that you might be doing something else do one of the username/passwords in one file you dont do to the other. Something along the lines of stripslashes() or html_entities

Link to comment
https://forums.phpfreaks.com/topic/107217-solved-login-problem/#findComment-549808
Share on other sites

ok, that works now, the pass in db is same as the one entered in pass, all works.

 

Though for some reason the below code is getting password as NULL.

<?php
mysql_connect($db_host,$db_username,$db_password) or die(mysql_error());
mysql_select_db($db_database) or die(mysql_error());

$username = $_POST['username']; 
$password = $_POST['password'];
$secpassword = md5("2392j3k2js21".$password.$username);

// Retrieve all the data from the "example" table
$result = mysql_query('SELECT * FROM owners WHERE username="$username"')
or die(mysql_error());  

// store the record of the table into $row
$row = mysql_fetch_array($result);
// Print out the contents of the entry 
if ($row['password'] == $secpassword){

echo ("Login success!");

} else {

echo ("Login Error!<br>Pass from mysql: ".$row['password']."<br>Pass from form: ".$secpassword." <br> Username entered in form".$_POST['username']."<br>");

}


?>

 

Cheers

Sean

Link to comment
https://forums.phpfreaks.com/topic/107217-solved-login-problem/#findComment-550996
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.