Hi,
I was wondering if someone could help me with the following.
I'm trying to make an admin page for my site but I'm new at this and still learning. After some searching I found this tutorial on the net, using sessions:
http://www.phptutorial.info/learn/session.html
it contains this script:
<?php if ($HTTP_POST_VARS["username"]=="") { ?>
<html>
<title>Our private pages</title>
<body>
In order to access this pages fill the form below:<BR>
<form method="post" action="index.php">
Username: <input type="text" name="username" size="20"><BR>
Password: <input type="password" name="password" size="15"><BR>
<input type="Submit" value="Submit">
</form>
</body>
</html>
<?php }else{
$username=$HTTP_POST_VARS["username"];
$password=$HTTP_POST_VARS["password"];
session_start();
if ($username=="Joe" AND $password=="hi"){ $permission="yes";}
if ($username=="Peter" AND $password=="hello"){ $permission="yes";}
$username=$HTTP_POST_VARS["username"];
session_register("permission");
session_register("username");
if ($permission=="yes"){
?>
<html>
<title>Our private pages</title>
<body>
Hi, you are allow to see these pages: <BR>
<A HREF="page1.php">Page 1</A><BR>
<A HREF="page2.php">Page 2</A>
</body>
</html>
<?php }else{ ?>
Error in username or password
<?php } ?>
<?php } ?>
This part works fine but when I try to acces page1.php it always sais that I'm not allowed, meaning it doesn't recognizes the variables of the session.
script for page1:
<?php
session_start();
if ($permission=="yes") {
?>
<html>
<title>Page 1</title>
<body>
Hi, welcome to Page 1 <BR>
This page is empty at the moment, but it will be very interesting in the next future
</body>
</html>
<?php }else{ ?>
You are not allowed to access this page
<?php } ?>
It there a mistake in the script or is ith something with the apache version and settings I'm running?
thank you for any help.