Code: Select all
<Html>
<form method="<? SELF ?>">
Username: <input type="text" name="user"><br>
Password: <input type="password" name="pass"><br>
<input type="submit" value="Log-in">
<?php
if ( ! $auth )
{
echo ("Please Log-In");
} elseif ($auth == true)
{
$mem = "members.php?user=$user&pass=$pass";
$send = urlencode($mem);
header ("Location:$send");
}
$auth = false; // Assume user is not authenticated
// Read the entire file into the variable $file_contents
$PW = $_REQUESTї'pass'];
$USER = $_REQUESTї'user'];
$filename = 'Users.txt';
$fp = fopen( $filename, 'r' );
$file_contents = fread( $fp, filesize( $filename ) );
fclose( $fp );
// Place the individual lines from the file contents into an array.
$lines = explode ( "\n", $file_contents );
// Split each of the lines into a username and a password pair
// and attempt to match them to $PHP_AUTH_USER and $PHP_AUTH_PW.
foreach ( $lines as $line ) {
list( $username, $password ) = explode( ':', $line );
if ( ( $username == "$USER" ) &&
( $password == "$PW" ) ) {
// A match is found, meaning the user is authenticated.
// Stop the search.
$auth = true;
break;
}
}PLEASE HELP ME