Advertisement
Jaamal

login.php for help

Jun 25th, 2013
140
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.92 KB | None | 0 0
  1. $username = $_POST['username'];
  2. $inPword = $_POST['password'];
  3. $lat =  $_POST['lat'];
  4. $lon =  $_POST['lon'];
  5.  
  6. $returnmessage = "";
  7. $loggedin = "";
  8.  
  9. $password_hash = "";
  10. $loggedinstatus = "";
  11.  
  12. $sel = mysqli_query($conn,"SELECT pword, loggedin FROM login WHERE uname = '$username'");
  13.  
  14. if(mysqli_num_rows($sel) < 1)
  15. {
  16.     $returnmessage = "BadLogin";
  17. }
  18.  
  19. while($fetch = mysqli_fetch_array($sel,MYSQLI_ASSOC))
  20. {
  21.     $password_hash = $fetch['pword'];
  22.     $loggedinstatus = $fetch['loggedin'];
  23. }
  24.  
  25. if(crypt($inPword, $password_hash) == $password_hash)
  26. {
  27.     switch($loggedinstatus)
  28.     {
  29.         case  "no":
  30.             $returnmessage = "AllGood";
  31.             $sel = mysqli_query($conn,"UPDATE login SET loggedin='yes' WHERE uname = '$username'");
  32.             break;
  33.         defaut:
  34.             $returnmessage = "alreadyin";
  35.             break;
  36.     }
  37. }
  38. else
  39. {
  40.     $returnmessage = "error";
  41. }
  42. echo json_encode(array("message" => $returnmessage, "uname" => $username));
  43.  
  44. mysqli_close($conn);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement