Guest User

Untitled

a guest
Dec 7th, 2018
114
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.98 KB | None | 0 0
  1. <?php
  2. include 'functions.php';
  3. /*
  4. * First we retrieve each of the relevant variables and remove any
  5. * non-alphanumeric characters filter them to protect against things such
  6. * as SQL Injection.
  7. */
  8. $username = isset($_POST['username']) ? $_POST['username'] : '';
  9. $username = preg_replace("/[^A-Za-z0-9]/", "", $username);
  10. $password = isset($_POST['password']) ? $_POST['password'] : '';
  11. $password = preg_replace("/[^A-Za-z0-9]/", "", $password);
  12. $phoneNum = isset($_POST['phone_number']) ? $_POST['phone_number'] : '';
  13. $phoneNum = preg_replace("/[^0-9]/", "", $phoneNum);
  14. $action = isset($_POST['action']) ? $_POST['action'] : '';
  15. switch ($action) {
  16. case 'token':
  17. $message = user_generate_token($username, $phoneNum);
  18. break;
  19. case 'login':
  20. $message = user_login($username, $password);
  21. break;
  22. default:
  23. echo 'do nothing';
  24. }
  25. header("Location: index.php?message=" . urlencode($message) . "&action=" . $action);
  26. ?>
Add Comment
Please, Sign In to add comment