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);
}
?>