Advertisement
Guest User

Untitled

a guest
May 4th, 2017
577
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.94 KB | None | 0 0
  1. <?php
  2. function register($username,$password,$email) {
  3.     $file = fopen("users.txt", "a");
  4.     fwrite($file,$username . '|' . $password . '|' . $email . "\n";
  5.     fclose($file);
  6. }
  7. function login($username,$password) {
  8.     $list = file_get_contents("users.txt");
  9.     $user_array = explode("\n", $list);
  10.     foreach($user_array as $user) {
  11.         if(strpos($user, $username))
  12.             $this_user = $user;
  13.     }
  14.     if(empty($this_user))
  15.         die("No user found");
  16.     $user_info = explode('|', $this_user);
  17.     if($password == $user_info[2])
  18.         echo "correct password";
  19.     else
  20.         die("bad password");
  21. }
  22. function reset_password($username) {
  23.     $list = file_get_contents("users.txt");
  24.     $user_array = explode("\n", $list);
  25.     foreach($user_array as $user) {
  26.         if(strpos($user, $username)
  27.             $this_user = $user;
  28.     }
  29.     $user_info = explode('|', $this_user);
  30.     mail($user_info[3], "Password Recovery", "Password: " . $user_info[2], "From: noreply@domain.tld");
  31.     echo "Password sent";
  32. }
  33. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement