I need some help. I want a user to log-in and use sessions to keep it so they are logged in until they log-out or exit the browser. My log-in script is simple and it works however I am having troubles addings sessions and reconizing. Here are my codes.
Main Login Page
<form method=post action="<?echo $PHP_SELF?>">
<table cellpadding=2 cellspacing=0 border=0>
<td><font size="2" face="Arial, Helvetica, sans-serif">CIIC Id:</font></td>
<td><input type="text" name="ciicid" size=10></td>
<tr>
<td><font size="2" face="Arial, Helvetica, sans-serif">Password:</font></td>
<td><input type="password" name="password" size=10></td>
<tr>
<td> </td>
<td><input type="submit" name="submit" value="Log In"></td>
</table>
</form>
<?php
$dbhost = 'localhost';
$dbusername = 'xxx';
$dbpasswd = 'xxx';
$database_name = 'xxx';
if ($submit) {
$db=mysql_pconnect("$dbhost","$dbusername","$dbpasswd") or die ("cant connect");
mysql_select_db("$database_name",$db) or die ("cant change");
$result=mysql_query("select * from links where ciicid='$ciicid'",$db) or die ("cant do it");
while ($row=mysql_fetch_array($result)) {
if ($row["password"]==$password) {
printf("Successfully Logged In!<a href=\"default.php?\"'>Click Here</a>");
}
}
}?>
<?php
//...snip...
if($affected_rows == 1) {
print 'validated';
//add the user to our session variables
$_SESSION['username'] = $ciicid;
}
else {
print 'not valid';
}
?>
Validate Sessions Script
<?php
session_start();
header("Cache-control: private");
if(empty($_SESSION['username'])) {
die('<font face=arial size=2>An error has ocurred. It may be that you have not logged in, or that
your session has expired.
Please try <a href="login.php">logging in</a> again or contact the
<a href="mailto:admin@example.com">system administrator</a></font>');
}
?>
Members page
<?php include('verify.php'); ?>
<!doctype html public "-//W3C//DTD HTML 4.01 Transitional//EN">
<HEAD>...
Please help me please. I would like to get this done soon. Thanks.