can u suggest me of how to fix this?
Main Topics
Browse All Topicshi, this is the code of mine.
some i got it from this site ( http://www.phpfreaks.com/t
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,$
{
//session_start();
//session_register('userna
//session_register('passwo
$username = $_POST['name'];
$password = $_POST['password_field'];
$_SESSION['name'] = $username;
$_SESSION['password'] = $password;
$sess_id = session_id();
header("Location: index.php?PHPSESSID=$sess_
exit;
}
else
{
$message = urlencode("<b>ERROR:</b> Username does not exist.");
header("Location: session1.php?message=$mess
exit;
}
}
else
{
$message = urlencode("<b>ERROR:</b> You must enter a username and password to enter.");
header("Location: session1.php?message=$mess
exit;
}
?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html
<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>
This Question has been solved and asker verified All Experts Exchange premium technology solutions are available to subscription members.
Experts Exchange has been collecting answers to technology questions since 1996…3 million and counting! If you have a question, chances are we already have your answer.
If you can't find the exact answer you're looking for, ask our exclusive community of 50,000 experts. You’ll get a personalized answer from a trusted professional.
Thousands of free tech tips, tricks, how-to’s and tutorials are available in our peer reviewed articles section. See for yourself how smart our experts are, no login required.
Access the answers to your technology questions today.
30-day free trial. Register in 60 seconds.
Members of the expert community talk about why the experience at Experts Exchange is different than what you will find anywhere else.

Try it out and discover for yourself.
30-day free trial. Register in 60 seconds.
Join the community of experts here and help other tech pros by answering question in your area of expertise. You can earn FREE access to all Experts Exchange's premium features and resources.
i tried making some change,
and this is wat i received from FIREFOX
------------------------
Notice: Undefined index: username_field in c:\program files\easyphp1-8\www\blog\
Notice: Undefined index: password_field in c:\program files\easyphp1-8\www\blog\
Warning: Cannot modify header information - headers already sent by (output started at c:\program files\easyphp1-8\www\blog\
------------
i've marked line number on the code below
-------------------
<?php
//session_start();
//header("Cache-control: private"); //IE 6 Fix
// header example
// --------------------------
// header("Location: http://www.example.com/");
// header("HTTP/1.0 404 Not Found");
// header("Content-Dispositio
//echo "Session ID : ".session_id()."<br>";
//echo "msg : " . $_GET['message'] . "<br>";
function validate_user($username, $password)
{
if(($username == 'admin') and ($password = 'admin'))
{
return true;
}
else
{
return false;
}
}
$username = trim($_POST['username_fiel
$password = trim($_POST['password_fiel
if (($username) AND ($password))
{
if (validate_user($username,$
{
session_start();
$_SESSION['name'] = trim($_POST['username_fiel
$_SESSION['password'] = trim($_POST['password_fiel
$sess_id = session_id();
header("Location: index.php?PHPSESSID=$sess_
exit;
}
else
{
$message = urlencode("<b>ERROR:</b> Username does not exist.");
header("Location: session1.php?message=$mess
exit;
}
}
else
{
$message = urlencode("<b>ERROR:</b> You must enter a username and password to enter.");
header("Location: session1.php?message=$mess
exit;
}
?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html
<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="username_field" 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>
Hi
I have modified your code a little bit... execute this and let me know if you still have any problem
Thanks
Ravi kiran
<?php
//session_start();
//header("Cache-control: private"); //IE 6 Fix
// header example
// --------------------------
// header("Location: http://www.example.com/");
// header("HTTP/1.0 404 Not Found");
// header("Content-Dispositio
//echo "Session ID : ".session_id()."<br>";
//echo "msg : " . $_GET['message'] . "<br>";
function validate_user($username, $password)
{
if(($username == 'admin') and ($password = 'admin'))
{
return true;
}
else
{
return false;
}
}
$username = trim($_POST['username_fiel
$password = trim($_POST['password_fiel
$ispost = trim($_POST['enter_button'
if($ispost == 'Enter') { // If condition added by Ravikiran
if (($username) AND ($password))
{
if (validate_user($username,$
{
session_start();
$_SESSION['name'] = trim($_POST['username_fiel
$_SESSION['password'] = trim($_POST['password_fiel
$sess_id = session_id();
header("Location: index.php?PHPSESSID=$sess_
exit;
}
else
{
$message = urlencode("<b>ERROR:</b> Username does not exist.");
header("Location: session1.php?message=$mess
exit;
}
}
else
{
$message = urlencode("<b>ERROR:</b> You must enter a username and password to enter.");
header("Location: session1.php?message=$mess
exit;
}
}
?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html
<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">
<!-- Start Added by Ravikiran -->
<tr>
<td colspan="4"><? echo $message;?></td>
</tr>
<!-- End Added by Ravikiran -->
<tr>
<td width="76" valign="bottom">Username </td>
<td colspan="3"><input name="username_field" 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>
Business Accounts
Answer for Membership
by: ravikiran_mullangiPosted on 2005-06-29 at 22:58:08ID: 14335743
This is because
age");
the else part (i hope your have given the file name session1.php to the above code)
else
{
$message = urlencode("<b>ERROR:</b> You must enter a username and password to enter.");
header("Location: session1.php?message=$mess
exit;
}
when ever your trying to access the page first time, it means the $username and $password are null,
so that this part of code executes ever time this page loads, it redirects to same page (session1.php) again and again this repeats....