I'm trying to authenticate a user ( right now just reading username from a username file and a password from a password file ). Here is my code... ( all of it ) ... and i will post the errors i get as well, any help would be appreciated greatly. 1st year PHP user ( 3 days experience )
<html>
<head>
<title>Untitled Document</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>
<body>
<?php
$LoginNameFile="LoginName.txt";
$PassWordFile="PassWord.txt";
$LoginName = $_POST['n_LoginName'];
$PassWord = $_POST['n_PassWord'];
$RemoteIP = getenv(REMOTE_ADDR);
echo '<h2>You have submitted the following values: </h2>';
echo 'Login Name: ', $LoginName;
echo '<br>';
echo 'Password: &nbs p; ', $PassWord;
echo '<br>';
echo '<br>';
echo 'Information submitted on: ';
echo date('l, F
jS, Y');
echo ' @ ';
echo date('g:i A, T');
echo '<br><br>You attempted to login from address : ';
echo $RemoteIP;
$fp_LoginNameFile = fopen($LoginNameFile, "r"); // open the LoginName file
while (!feof($fp_LoginNameFile) ) // compare each entry with entered LoginName
{
$Login = fgets($fp_LoginNameFile, 20);
if ($Login == LoginName . "\r\n")
{
echo 'Correct Login Name';
break;
}
else
{
echo 'Invalid Login Name';
}
}
fclose($fp_LoginName);
$fp_PassWordFile = fopen($PassWordFile, "r"); // open the PassWord file
fclose($fp_PassWord);
?>
</body>
</html>
Password file is named PassWord.txt and is stored in the same directory as my .php code... as LoginName.txt is also stored there.
I get the following output for the page after it executes
Notice: Use of undefined constant REMOTE_ADDR - assumed 'REMOTE_ADDR' in C:\Inetpub\wwwroot\show1.php on line 14
You have submitted the following values:
Login Name: webmaster
Password: password
Information submitted on: Tuesday, February 10th, 2004 @ 9:41 PM, Central Standard Time
You attempted to login from address : 127.0.0.1
Notice: Use of undefined constant LoginName - assumed 'LoginName' in C:\Inetpub\wwwroot\show1.php on line 32
Invalid Login Name
Notice: Undefined variable: fp_LoginName in C:\Inetpub\wwwroot\show1.php on line 42
Warning: fclose(): supplied argument is not a valid stream resource in C:\Inetpub\wwwroot\show1.php on line 42
Notice: Undefined variable: fp_PassWord in C:\Inetpub\wwwroot\show1.php on line 46
Warning: fclose(): supplied argument is not a valid stream resource in C:\Inetpub\wwwroot\show1.php on line 46
Any clues? ( I'm sure ya have a few hundred for me )