Advertisement
Guest User

Untitled

a guest
Nov 9th, 2016
109
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.61 KB | None | 0 0
  1. <?php
  2.  
  3. header("Access-Control-Allow-Origin: *");
  4. header("Content-Type: application/json; charset=UTF-8");
  5.  
  6.  
  7.  
  8.  
  9. $conn = new mysqli("localgost", "root", "", "moeza_Dealish");
  10.  
  11.  
  12. $username=$_GET["un"];
  13. $email = $_GET["email"];
  14. $password=$_GET["ps"];
  15. $password=md5($password);
  16.  
  17. $phone=$_GET["ph"];
  18. $address=$_GET["add"];
  19.  
  20.  
  21. // To protect MySQL injection for Security purpose
  22.  
  23. //$username = stripslashes($username);
  24. //$password = stripslashes($password);
  25. //$phone = stripslashes($phone);
  26. //$address = stripslashes($address);
  27.  
  28.  
  29.  
  30. //$username = mysql_real_escape_string($username);
  31. //$password = mysql_real_escape_string($password);
  32. //$phone = mysql_real_escape_string($phone);
  33. //$address = mysql_real_escape_string($address);
  34.  
  35.  
  36. $check="SELECT * FROM users WHERE username = '$username'";
  37. $rs = mysqli_query($conn,$check);
  38. $data = mysqli_fetch_array($rs, MYSQLI_NUM);
  39.  
  40. if($data[0] > 1) {
  41. $outp='{"result":{"created": "0" , "exists": "1" }';
  42. }
  43. else{
  44. $sql='INSERT INTO users (username , email , password , phone , address , role , verified ) VALUES ("'.$username.'", "'.$email.'", "'.$password.'", "'.$phone.'", "'.$address.'", "2", 1)';
  45. //echo $sql;
  46. if ($conn->query($sql) === TRUE) {
  47. //$outp='{"result":{"created": "1", "exists": "0" }';
  48. $outp = array("result" => array("created" => "1", "exists" => "0"));
  49. }
  50. else {
  51. echo $conn->error;
  52. $outp = array("result" => array("created" => "0", "exists" => "0"));
  53. }
  54. }
  55. $outp = json_encode($outp);
  56. echo $outp;
  57.  
  58. $conn->close();
  59.  
  60. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement