hi, this is the code of mine.
some i got it from this site (
http://www.phpfreaks.com/tutorials/77/1.php )
it's a tut about 'Customized Timeout Sessions'
i am trying to incoperate tat site code with mine. but i have very little knowleage about header thingly.
and i not sure what i did wrong here.
any suggestion would be appreciate, and some comment on how header works would be great.
what i know now about header is, we use header to redirect to other site, or pop user for a file to download.
anyway, this is my code,
and this is the error i received from firefox when i tried to run the code.
--------------------------
----------
----------
----------
----------
----------
----------
----------
----------
----------
----------
----------
----------
----
redirection limit for this URL exceeded. unable to load the requestes page. this may by caused by cookies that area blocked.
--------------------------
----------
----------
----------
----------
----------
----------
----------
----------
----------
----------
----------
----------
------
code
-----------------
<?php
session_start();
header("Cache-control: private"); //IE 6 Fix
$username = null;
function validate_user($username, $password)
{
if(($username == 'admin') and ($password = 'admin'))
{
return true;
}
else
{
return false;
}
}
if (($username != null) && ($password != null ))
{
if (validate_user($username,$
password) == true)
{
//session_start();
//session_register('userna
me'); // not good due to security reason
//session_register('passwo
rd');
$username = $_POST['name'];
$password = $_POST['password_field'];
$_SESSION['name'] = $username;
$_SESSION['password'] = $password;
$sess_id = session_id();
header("Location: index.php?PHPSESSID=$sess_
id&new_log
in=1");
exit;
}
else
{
$message = urlencode("<b>ERROR:</b> Username does not exist.");
header("Location: session1.php?message=$mess
age");
exit;
}
}
else
{
$message = urlencode("<b>ERROR:</b> You must enter a username and password to enter.");
header("Location: session1.php?message=$mess
age");
exit;
}
?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "
http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title>Untitled Document</title>
</head>
<body>
<form name="form1" method="post" action="session1.php">
<table width="232" height="94" border="0">
<tr>
<td width="76" valign="bottom">Username </td>
<td colspan="3"><input name="name" type="text" id="name_filed"></td>
</tr>
<tr>
<td valign="bottom"><br>
Password </td>
<td colspan="3"><input type="password" name="password_field"></td
>
</tr>
<tr>
<td rowspan="2"> </td>
<td colspan="2"><input type="checkbox" name="checkbox" value="checkbox">
remember me?</td>
<td width="49" rowspan="2"> </td>
</tr>
<tr>
<td width="46"><input name="enter_button" type="submit" id="enter_button" value="Enter"></td>
<td width="98"><input name="reset_button" type="reset" id="reset_button" value="Reset"></td>
</tr>
</table>
</form>
<a href = "session2.php"> GO2- ession2 </a>
</body>
</html>