Snippet to check username / password against a text file
Compares fields seperated by a pipe "|" to strings sent via POST variables
<?
// file where there's on each line a username|password
$data = file('path/to/file.txt'); // read the file
for($x = 0; $x < count($data); $x++){
$parts = explode('|',$data[$x]);
$name_check = strpos($parts[0],$_POST['name']);
if($name_check === true){
$name = 1;
}
else{
$name = 0;
}
$pass_check = strpos($parts[1],$_POST['password']);
if($pass_check === true){
$pass = 1;
}
else{
$pass = 0;
}
if($name == 1 && $pass == 1){
echo 'hello '.$_POST['name'];
}
}
?>
|
|
Top