Can anyone tell me what is wrong with this script:
<html>
<head>
<title>.::Bad Habits - Login Result</title>
<link href="style.css" rel="stylesheet" type="text/css">
</head>
<body bgcolor="#000000">
<center>
<?php
//CREATE VARIABLES FROM POST
$user = $_POST['username'];
$pass = $_POST['password'];
//GET USERS DETAILS
$connection = odbc_connect('database','','');
$query = "SELECT * FROM User WHERE (Username LIKE '%$user%')";
$queryexe = odbc_exec($connection, $query);
//CREATE VARIABLES FROM DETAILS
$id = odbc_result($queryexe, 1);
$uname = odbc_result($queryexe, 2);
$pword = odbc_result($queryexe, 3);
$name = odbc_result($queryexe, 4);
//VALIDATE USER
session_start();
if ($user==$uname){
if ($pass==$pword){
setcookie("uname","$user",time()+1296000,"/");
setcookie("pass","$pass",time()+1296000,"/");
echo "<font>Thanks for logging in!<br />You will be redirected to the home page in a few seconds!";
} else {
echo "<font>Your password is incorrect!";
}
}
else {
echo "<font>Incorrect Username!";
}
?>
</body>
</html>
The user's details are being passed from another php script. Im not sure where the problem lies but I don't think the cookie is being set properly. Basically, I am logging in succesfully but the homepage isn't accepting that I am by still displaying Welcome, anonymous.
Cheers,
Bailz.