Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- function register($username,$password,$email) {
- $file = fopen("users.txt", "a");
- fwrite($file,$username . '|' . $password . '|' . $email . "\n";
- fclose($file);
- }
- function login($username,$password) {
- $list = file_get_contents("users.txt");
- $user_array = explode("\n", $list);
- foreach($user_array as $user) {
- if(strpos($user, $username))
- $this_user = $user;
- }
- if(empty($this_user))
- die("No user found");
- $user_info = explode('|', $this_user);
- if($password == $user_info[2])
- echo "correct password";
- else
- die("bad password");
- }
- function reset_password($username) {
- $list = file_get_contents("users.txt");
- $user_array = explode("\n", $list);
- foreach($user_array as $user) {
- if(strpos($user, $username)
- $this_user = $user;
- }
- $user_info = explode('|', $this_user);
- mail($user_info[3], "Password Recovery", "Password: " . $user_info[2], "From: noreply@domain.tld");
- echo "Password sent";
- }
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement