Having difficulties with the MD5 function
Posted: Fri Sep 03, 2010 8:46 pm
Hi,
I am trying to create a login script. From my register page, the password is md5 encrypted and I can see that is via the database browse function. I then have a login form and this is the code for my process login page:
However, if I print $count, it returns 0, not 1. This is driving me insane. Any ideas why this wouldn't be working? THanks
I am trying to create a login script. From my register page, the password is md5 encrypted and I can see that is via the database browse function. I then have a login form and this is the code for my process login page:
Code: Select all
<?php
include("config.php");
//Retrieves nickname and password fields from login.php and puts them into variables $nickname and $password
$nickname = $_POST['nickname'];
$password = md5($_POST['password']);
//Counts the number of rows where $nickname and $password are in the database. If the password matches the nickname, this value should be 1. Puts this value into $count variable
$sql = "SELECT * FROM medieval WHERE nickname = '$nickname' AND password = '$password'";
$query = mysql_query($sql);
$count = mysql_num_rows($query);
$time = time()+ 3600;
//If count == 1, sets cookie
if($count == 1)
{
setcookie(nickname, $_POST['nickname'], $time);
}
?>