Jump to content

[SOLVED] n00b login problem


chocopi

Recommended Posts

When the user tries to login it does not recognise their password. so if they type in their password it does not login but if they leave the password field blank, it does.

 

<?php

require_once ('page_header.php');

session_start();
$username = $_POST['username'];
$password = md5($_POST['password']);

$query = "SELECT * FROM users WHERE username='$username' and password='$password'";

$result = mysql_query($query);

if (mysql_num_rows($result) != 1) {
$error = 'Bad Login';

//html code

	if($_POST){
		print ("<font color=\"#ff0000\"> \n");
		print ("<center> \n");
		echo ("Incorrect Username and Password combination.");
		print ("</center> \n");
		print ("</font> \n");
		require_once ('page_footer.php');
	}

} else {
    $_SESSION['username'] = '$username';
    require_once ('memberspage.php');
}

?>

 

Thanks in advance,

 

~ Chocopi

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

ok i found the problem but it looks fine to me

 

if ($raw_password !== $raw_confirm){
echo ("Your passwords must be identical.");
require_once ('page_footer.php');
die ("");
} else {
$password = md5($_POST['raw_password']);
}

 

The idea of this is that it validates the raw_password and raw_confirm and if it is true then it sets the md5 of raw_password to $password. But it hasnt worked :'(

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.