...

View Full Version : Password function error



mattd8752
12-29-2006, 09:50 PM
Could someone find what the syntax error is. You can see what the script does at mattdsworld.theicy.net/commands/.



<?php
function requestpass()
{
$filename = "./data/pass.txt";
$handle = fopen($filename, "r");
$cpass = fread($handle, filesize($filename));
fclose($handle);
$pass = $_POST['pass'];
$pass = md5($pass);
if (!isset ($_POST['Login'] && $pass != $cpass)) // display form
{
?>
<form method="POST" action="<?php echo $PHP_SELF; ?>">
<p>Password: <input type="text" name="pass" size="20"><input type="submit" value="Login" name="Login"></p>
</form>
<?php
}
else{ // correct password. Display page.
}
?>


<?php
function requestpassend()
{
}
}
?>

anarchy3200
12-29-2006, 09:55 PM
The line:
if (!isset ($_POST['Login'] && $pass != $cpass)) // display form
should be:
if (!isset($_POST['Login']) && $pass != $cpass) // display form
Note the moved bracket from the end to after the $_POST['Login']
:thumbsup:

mattd8752
12-29-2006, 10:08 PM
TYVM, that fixed the problem. I didn't see that when I added the && != part. I still have a problem, it shows the pass req'd to see this on index:


<?php
include './scripts/requestpassword.php';
?>
<html>
<head>
<title>Thepage</title>
</head>
<body>
<?php requestpass(); ?>
Pass required to see this.
<?php requestpassend(); ?>
</body>
</html>


I did fix the main part.



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum