<?PHP
session_start();
$usr = $_POST['username'];
$pass = $_POST['password'];
$filename = 'users.txt';
$fp = fopen( $filename, 'r' );
$file_contents = fread( $fp, filesize( $filename ) );
fclose( $fp );
$lines = explode ( "\n", $file_contents );
foreach ( $lines as $line ){
list( $username, $password ) = explode( ':', $line );
}
if($username !== $usr){
echo 'invalid username';
die;
}
if ( ( $usr == $username ) &&
( $pass == $password ) ) {
echo 'Valid User. Login Successful';
}
else{
echo 'Invalid Password';
}
?>