[SOLVED] Stumped..

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
d3ad1ysp0rk
Forum Donator
Posts: 1661
Joined: Mon Oct 20, 2003 8:31 pm
Location: Maine, USA

[SOLVED] Stumped..

Post by d3ad1ysp0rk »

Code: Select all

<?PHP //linkadmin.php
$correct = "4985"; //change password here
$pass = $_SESSION['apass'];
ob_start();
echo "Session: ".$_SESSION['apass']."<br>";
echo "Variable: ".$pass."<br>";
echo "Correct value: ".$correct."<br>";
if($pass==$correct){
   echo "<html>\n<body>\nLogged in!\n</body>\n</html>";
}
else {
   if($_POST['pass']==$correct){
      $_SESSION['apass'] = $correct;
      header("Location:linkadmin.php?pass");
   }
   if(isset($_POST['pass']) && $_POST['pass']!=$correct) {
      echo "Incorrect Password!<br>\n";
   }
echo <<<EOT
<html>
<body>
<form action="linkadmin.php" method="post" name="passform">
Admin Password: <input type="text" name="pass"><br>
<input type="submit" name="submit" value="Log in">
</form>
</body>
</html>
EOT;
ob_flush();
}
?>
Try it out here:
http://www.404-design.net/linkadmin.php

some of the code is debug stuff, such as header("location:linkadmin.php?pass") isntead of linkadmin.php, is to see if that loop ran.

but even when it runs, and then redirects you, the session variable is empty..
User avatar
JAM
DevNet Resident
Posts: 2101
Joined: Fri Aug 08, 2003 6:53 pm
Location: Sweden
Contact:

Post by JAM »

Missing session_start()
d3ad1ysp0rk
Forum Donator
Posts: 1661
Joined: Mon Oct 20, 2003 8:31 pm
Location: Maine, USA

Post by d3ad1ysp0rk »

ahhhh!

thank you.. lol
Post Reply