I still can't get a working grasp on how fopen() works... I'm trying to implement it into the code at the bottom of the page, and I can't seem to get it to work. The first part marked troubled also needs help; any help of which you can offer would be highly appriciated - I've been trying to get fopen() to work for two days now, with no luck. What am I missing?
(The text file being written is for HUMAN reading, not to be read by a script.)
<?PHP
####################
#The Troubled Part
###################
//don't let evil people load the page directly
if ($PHP_REFERER = $PHP_SELF) {
die('Please do NOT load this page directly!');
}
##################
#End of Troubled Part
################
//if the correct password & username...
if ($uname == "admin" && $passwd == "admin") {
//log them in...
echo "You logged into the admin panel. Wheeeeeeeee!";
} elseif ($uname && $passwd) {
//if it's a wrong password
echo "Looser. Wrong password/username and such. You're such a misfit. But you might want to <a href='index.html'>try again</a>, mabye?";
echo "<br>";
echo " <br>";
echo "I'm afraid that <font size='6' color='red'>";
echo $passwd;
echo "</font> isnt' the right password. But I've logged it just in case it just for fun. Be scared.";
//let them have it!
###############
#The Troubled Part
###############
//open the file in read AND write modes, at the same time.
$fp = fopen("pasttries.txt", "a");
//write the try to the end of the file (I know this part is TOTALLY wrong)
$fp = $fp . " ..::.. " . $passwd;
//close the file
fclose($handle);
####################
#End of the Troubled Part
###################
//but what if I forogt to enter something?
} else {
echo "<font color='red' size='3'>You forgot to enter";
if($passwd = "") {
// missing password.
echo " you password";
} elseif($uname = "") {
//missing username
echo " your username";
} else {
//otherwise, something screwed up!
echo "<B>SYSTEM ERROR</b>";
}
//finish up the </font> and add emphasis!
echo "!</font>";
}
?>