Advertisement
Guest User

Untitled

a guest
Jun 15th, 2015
295
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. require(“Conn.php”);
  3. require(“MySQLDao.php”);
  4. $email = htmlentities($_POST[“email”]);
  5. $password = htmlentities($_POST[“password”]);
  6.  
  7. $returnValue = array();
  8.  
  9. if(empty($email) || empty($password))
  10. {
  11. $returnValue[“status”] = “error”;
  12. $returnValue[“message”] = “Missing required field”;
  13. echo json_encode($returnValue);
  14. return;
  15. }
  16.  
  17. $dao = new MySQLDao();
  18. $dao->openConnection();
  19. $userDetails = $dao->getUserDetails($email);
  20.  
  21. if(!empty($userDetails))
  22. {
  23. $returnValue[“status”] = “error”;
  24. $returnValue[“message”] = “User already exists”;
  25. echo json_encode($returnValue);
  26. return;
  27. }
  28.  
  29. $secure_password = md5($password); // I do this, so that user password cannot be read even by me
  30.  
  31. $result = $dao->registerUser($email,$secure_password);
  32.  
  33. if($result)
  34. {
  35. $returnValue[“status”] = “Success”;
  36. $returnValue[“message”] = “User is registered”;
  37. echo json_encode($returnValue);
  38. return;
  39. }
  40.  
  41. $dao->closeConnection();
  42.  
  43. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement