Advertisement
Guest User

Untitled

a guest
Feb 8th, 2017
86
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.64 KB | None | 0 0
  1. <?php
  2. session_start();
  3.  
  4. include('connect.php');
  5.  
  6. // Get JSON from UI
  7. $postdata = file_get_contents("php://input");
  8. $request = json_decode($postdata);
  9.  
  10. $username = $request->username;
  11. $password = $request->password;
  12. $password = md5($password);
  13.  
  14. $query = "SELECT * FROM c_security_user WHERE c_security_user.username = '$username' AND c_security_user.password = '$password'";
  15. $result = mysql_query($query);
  16. $data = mysql_fetch_array($result);
  17.  
  18. if (mysql_num_rows($result) != 0) {
  19. $_SESSION['username'] = $data['username'];
  20. $msg = array('status' => 'success');
  21. } else {
  22. $msg = array('status' => 'failed');
  23. }
  24.  
  25. echo json_encode($msg);
  26. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement