Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- // http://answers.yahoo.com/question/index?qid=20110906181257AAl7Fre
- $user = strtolower( $_POST['user'] );
- $pass = $_POST['pass'];
- $lines = file('/assets/people.txt');
- foreach($lines as $line){
- $parts = explode(':',$line);
- if($parts[0] == $user && $parts[1] == $pass){
- // Username & Password Combination is all good.
- echo 'That is a Good Username and Password Combo';
- }else{
- // Invalid Username/Password Combination
- echo 'Invalid Username/Password Combo';
- }
- }
- // This will work fine for a small number of entries, but for a larger list of people, this
- // approach would be very taxing on your system.
- /* ALTERNATIVE APPROACH
- $user = strtolower( $_POST['user'] );
- $pass = $_POST['pass'];
- $combo = $user . ':' . $pass . PHP_EOL;
- $list = file_get_contents( '/assets/people.txt');
- if(strpos($list,$combo) !== false){
- // Username & Password Combination is all good.
- echo 'That is a Good Username and Password Combo';
- }else{
- // Invalid Username/Password Combination
- echo 'Invalid Username/Password Combo';
- }
- */
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement