Hi. I’m having this days some problems to a login form. I connected my php to a MySQL database.
The problem is when I log into the site. The login form should verify my datas and redirect me to a PHP page reserved only to logged people but it now works.
This is a part of the PHP code:
[php]<?php
include (“include/functions.php”);
include (“resources/sqlconnector.php”);
session_start();
session_regenerate_id(TRUE);
if(isset($_SESSION[‘username’]) || (isset($_COOKIE[‘username’]) && isset($_COOKIE[‘pass’])))
{
header(‘location:reserved.php’);
exit;
}
if (isset($_POST[‘username’]) && isset($_POST[‘pass’]) && strlen($_POST[‘username’]) > 0 && strlen($_POST[‘pass’]) > 0)
{
$name = htmlspecialchars($POST[‘username’]);
for($i = 0; $i < strlen($name); $i++) if($name[$i] == ’ ') $name[$i] = '’;
$pass = num_hash(htmlspecialchars($_POST[‘pass’]));
$query = “SELECT * FROM users WHERE LOWER(Name) = LOWER(’$name’) AND password_hash = $pass”;
$result = mysql_query($query);
if($result)
{
if($row = mysql_fetch_array($result))
{
if($row[‘Banned’] == 1)
{
echo"You are banned!";
}
else
{
$_SESSION[‘username’] = $name;
$_SESSION[‘pass’] = $pass;
if(isset($_POST[‘remember’]))
{
setcookie(‘username’, $name);
setcookie(‘pass’, $pass);
}
echo"You are logged in!";
header(‘location:reserved.php’);
exit;
}
}
else
{
echo “Retype Username and Password”;
}
}
else
{
exit('<b>Unable to execute the query</b>');
}
}
?>[/php]
When I click on the input “submit”, it refresh and I can’t log in. Can anyone help me?
