don't know if php.ini settings are important here, but i'll include them anyway (the ones i think might be relevant):
session.save_handler = files
session.use_cookies = On
session.save_path = /tmp
then, i have 2 files, hello.php4
and accesscontrol.php4 :
the header (#!/usr/local/bin/php4) has to be there per host's instructions.
it's long to explain why i'm only checking for a set password, so let's leave that out of the discussion for now.
when i run hello.php4 the error message i get is
#!/usr/local/bin/php4
Warning: Cannot send session cookie - headers already sent by (output started at /cgi/hello.php4:2) in /cgi/accesscontrol.php4 on line 5
Warning: Cannot send session cache limiter - headers already sent (output started at /cgi/hello.php4:2) in /cgi/accesscontrol.php4 on line 5
line 5 of accesscontrol.php4 is session_start();
so how do i get tjis fixed?
--------------------------------------------------
Goals are dreams with deadlines
-------------------------------------
session.save_handler = files
session.use_cookies = On
session.save_path = /tmp
then, i have 2 files, hello.php4
Code:
#!/usr/local/bin/php4
<?php include 'accesscontrol.php4'; ?>
<!DOCTYPE html PUBLIC "-//W3C/DTD XHTML 1.0 Transitional//EN"
"[URL unfurl="true"]http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">[/URL]
<html xmlns="[URL unfurl="true"]http://www.w3.org/1999/xhtml">[/URL]
<head>
<title> Members-Only Page </title>
<meta http-equiv="Content-Type"
content="text/html; charset=iso-8859-1
</head>
<body>
<p>Hello, <?=$username?>! You have entered a members-only area
of the site. Don't you feel special?</p>
</body>
</html>
and accesscontrol.php4 :
Code:
#!/usr/local/bin/php4
<?php // accesscontrol.php
session_start();
$uid = isset($_POST['uid']) ? $_POST['uid'] : $_SESSION['uid'];
$pwd = isset($_POST['pwd']) ? $_POST['pwd'] : $_SESSION['pwd'];
if(!isset($uid)) {
?>
<!DOCTYPE html PUBLIC "-//W3C/DTD XHTML 1.0 Transitional//EN"
"[URL unfurl="true"]http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">[/URL]
<html xmlns="[URL unfurl="true"]http://www.w3.org/1999/xhtml">[/URL]
<head>
<title> Please Log In for Access </title>
<meta http-equiv="Content-Type"
content="text/html; charset=iso-8859-1" />
</head>
<body>
<h1> Please Sign In: </h1>
<p>You must log in to access this area of the site. If you are
not a registered user, <a href="signup.php">click here</a>
to sign up for instant access!</p>
<p><form method="post" action="<?=$_SERVER['PHP_SELF']?>">
User ID: <input type="text" name="uid" /><br />
Password: <input type="password" name="pwd" /><br />
<input type="submit" value="Sign In" />
</form></p>
</body>
</html>
<?php
exit;
}
$_SESSION['uid'] = $uid;
$_SESSION['pwd'] = $pwd;
if ($pwd != "hello" ) {
unset($_SESSION['uid']);
unset($_SESSION['pwd']);
?>
<!DOCTYPE html PUBLIC "-//W3C/DTD XHTML 1.0 Transitional//EN"
"[URL unfurl="true"]http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">[/URL]
<html xmlns="[URL unfurl="true"]http://www.w3.org/1999/xhtml">[/URL]
<head>
<title> Access Denied </title>
<meta http-equiv="Content-Type"
content="text/html; charset=iso-8859-1" />
</head>
<body>
<h1> Access Denied </h1>
<p>Your user ID or password is incorrect, or you are not a
registered user on this site. To try logging in again, click
<a href="<?=$_SESSION['PHP_SELF']?>">here</a>. To register for instant
access, click <a href="signup.php">here</a>.</p>
</body>
</html>
<?php
exit;
}
$username = $uid;
?>
the header (#!/usr/local/bin/php4) has to be there per host's instructions.
it's long to explain why i'm only checking for a set password, so let's leave that out of the discussion for now.
when i run hello.php4 the error message i get is
#!/usr/local/bin/php4
Warning: Cannot send session cookie - headers already sent by (output started at /cgi/hello.php4:2) in /cgi/accesscontrol.php4 on line 5
Warning: Cannot send session cache limiter - headers already sent (output started at /cgi/hello.php4:2) in /cgi/accesscontrol.php4 on line 5
line 5 of accesscontrol.php4 is session_start();
so how do i get tjis fixed?
--------------------------------------------------
Goals are dreams with deadlines
-------------------------------------