I try to run this following sample script.
The returning error is
Notice: Undefined index: username in D:\Aplikasi\London\joe.php on line 1
I have no space before 1st php tag. It seems to be a setting problems. I use win2k and php 4.3.1
Please advise me guys...
<?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="joe.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 } ?>