Guest User

Untitled

a guest
Dec 12th, 2018
84
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.88 KB | None | 0 0
  1. public function signIn(){
  2. $allowed = ['user', 'password'];
  3. $success = false;
  4.  
  5. if($_POST){
  6. foreach($allowed as $a){
  7. if(isset($_POST[$a])){
  8. $success = !empty($_POST[$a]) ? true : false;
  9. break;
  10. }else{
  11. $success = false;
  12. break;
  13. }
  14. }
  15. if($success){
  16. $user = stripslashes(strip_tags(rtrim($_POST[$allowed['user']])));
  17. $pass = hash('sha512', stripslashes(strip_tags(r_trim($_POST[$allowed['password']]))));
  18. echo 'ok';
  19. }else{
  20. $errors[] = 'User or password incorrect, please retry!';
  21. }
  22. }else{
  23. $errors[] = 'Post data are invalid, refresh page and try i!';
  24. }
  25. }else{
  26. $errors[] = "Post data are empty, refresh page and try i!";
  27. }
  28. echo $errors[0];
  29. }
Add Comment
Please, Sign In to add comment