I have a login form with username and password field
after you click submit it checks if somebody exists and gets his UserID.
Now I want if the user exists set a cookie with the UserId in it.
But this seems not to work with me.
Can somebody say what I do wrong or help me
This is the code:
<?php
if(isset($user)&&isset($pass))
{
include("dbconnect.inc");
$query_recordset1= "select UserID from tblusers where Username='$user' and Password='$pass'";
$recordset1=mysql_query($query_recordset1,$db) or
die (mysql_error());
$row_recordset1=mysql_fetch_assoc($recordset1);
$totalrows_recordset1=mysql_num_rows($recordset1);
$check=$row_recordset1['UserID'];
if($check<>null)
{
//echo "<br><br>";
//echo "your userid is: (without cookie)";
//echo $check;
//echo "<br><br>The password was write ";
//echo $user;
setcookie("count", $check,time()+30);
}
else
{
echo "The username or password that you gave was wrong, push the backbutton to retry";
}
}
else
{
?>
<html>
<head>
<title>Login Page</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>
<body bgcolor="#999999" text="#FFCC33">
<div align="center"><font size="7"><strong>Welcome To the Online Movie Database
</strong></font><br><br><br>
<strong><font size="5">Fill in your account info to login into the database
</font></strong><br><br>
<form action="login.php" method="post">
<table width="50%" border="0">
<tr>
<td><div align="right">Username:</div></td>
<td><input type="text" name="user"></td>
</tr>
<tr>
<td><div align="right">Password:</div></td>
<td><input type="password" name="pass"></td>
</tr>
<tr>
<td><div align="right"><input type="submit" value="Send" name="Submit"></div></td>
<td><input type="reset" value="Reset" Name="Reset"></td>
</tr>
</table>
</form>
<br>
<br>
Don't have an account <a href="mailto:mistercash@theresident.nl">mail me</a>
and give me your username and other info like from where you got this link and
other info.</div>
</body>
</html>
<?php
}
?>