Guest User

Untitled

a guest
Nov 1st, 2018
141
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.31 KB | None | 0 0
  1. <?php
  2. if(isset($_POST['submit_reg'])){
  3. $var=file("data.txt");
  4. $userData = $_POST['email'] . " " . $_POST['password'] . "rn";
  5. $lines=0;
  6. $db = fopen("data.txt", "a+");
  7. foreach($var as $key=>$value){
  8. $user = (explode(' ', $value));
  9. if ($_POST["password"] === $_POST["confirm_password"]) {
  10. //print_r($value);
  11. if (trim($user[0]) == $_POST['email']) {
  12. $lines++;
  13. }
  14. break;
  15.  
  16. }
  17. }
  18. if($lines){
  19. echo "The email is already exists ";
  20. }else{
  21. fwrite($db,$userData."rn");
  22. fclose($db);
  23. echo "you are registered successfully ";
  24. }
  25. }
  26. ?>
  27.  
  28. <?php
  29. if (isset($_POST['submit_log'])) {
  30. $email =isset($_POST['email']);
  31. $password =isset($_POST['password']);
  32. $file = explode( PHP_EOL, file_get_contents( "data.txt" ));
  33. $auth = false;
  34. foreach( $file as $line ) {
  35. list($email, $password) = explode(" ", $line);
  36.  
  37. if ($_POST['email'] == $email && $_POST['password'] == $password) {
  38. $auth =true;
  39. break;
  40. }
  41. }
  42. if($auth) {
  43. echo "Login successfull!";
  44. } else {
  45. echo "Invalid username or password";
  46. }
  47. }
  48. ?>
Add Comment
Please, Sign In to add comment