snippet to check username / password against a text file
compares fields seperated by a pipe "|" to strings sent via POST variables

string compare” makes use of the built-in PHP functions file( ), count( ), explode( ) and strpos( ).

01 <?
02   
03   // lets say you have a file where there's on each line something like
04   // username|password
05   
06   $data = file('path/to/file.txt'); // read the file
07   
08   for($x = 0; $x < count($data); $x++)
09   {
10       $parts = explode('|',$data[$x]);
11       $name_check = strpos($parts[0],$_POST['name']);
12       if($name_check === true) // important are the ===
13       {
14            $name = 1;
15       }else{
16            $name = 0;
17       }
18       $pass_check = strpos($parts[1],$_POST['password']);
19       if($pass_check === true) // important are the ===
20       {
21            $pass = 1;
22       }else{
23            $pass = 0;
24       }
25       if($name == 1 && $pass == 1)
26       {
27           echo 'hello '.$_POST['name'];
28           // do whatever
29       }
30   }
31   
32   
33 ?>