Advertisement
Guest User

Untitled

a guest
Jan 6th, 2017
95
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.24 KB | None | 0 0
  1. public function StoreInfo($password,$confirmpassword,$birthdate)
  2. {
  3. //$elite_id = mysql_insert_id();
  4. //$date = date('YYYY-MM-DD');
  5. $stmt = $this->conn->prepare("INSERT INTO ibeInsert(password,confirmpassword,birthdate,elite_id) VALUES(?, ?, ?,LAST_INSERT_ID())");
  6. $stmt->bind_param("sss", $password, $confirmpassword, $birthdate);
  7.  
  8. $result = $stmt->execute();
  9. $stmt->close();
  10.  
  11. if ($result) {
  12. $stmt = $this->conn->prepare("SELECT password, confirmpassword,birthdate,elite_id FROM ibeInsert");
  13. $stmt->execute();
  14.  
  15. $stmt-> bind_result($token2,$token3,$token4,$token1);
  16. while ( $stmt-> fetch() ) {
  17. $user["password"] = $token2;
  18. $user["confirmpassword"]=$token3;
  19. $user["birthdate"] = $token4;
  20. $user["elite_id"]=$token1;
  21. }
  22. $stmt->close();
  23. return $user;
  24. } else {
  25. return false;
  26. }
  27.  
  28.  
  29. }
  30. //for gender country city
  31. public function StoreEliteInfoTo($gender,$country,$city)
  32. {
  33. // $this->conn;
  34. // $elite_id = mysql_insert_id();
  35. $stmt = $this->conn->prepare("INSERT INTO ibeInsert(gender,country,city,elite_id) VALUES(?, ?, ?, LAST_INSERT_ID())");
  36. $stmt->bind_param("sss", $gender, $country, $city);
  37. $result = $stmt->execute();
  38.  
  39. $stmt->close();
  40. if ($result) {
  41. $stmt = $this->conn->prepare("SELECT gender, country,city,elite_id FROM ibeInsert");
  42. $stmt->execute();
  43. $stmt-> bind_result($token2,$token3,$token4,$token1);
  44. while ( $stmt-> fetch() ) {
  45. $user["gender"] = $token2;
  46. $user["country"]=$token3;
  47. $user["city"] = $token4;
  48. $user["elite_id"]=$token1;
  49. }
  50. $stmt->close();
  51. return $user;
  52. } else {
  53. return false;
  54. }
  55.  
  56. }
  57.  
  58. //call function
  59.  
  60. <?php
  61.  
  62. require_once 'update_user_info.php';
  63. $db = new update_user_info();
  64.  
  65. // json response array
  66. $response = array("error" => FALSE);
  67.  
  68. if (isset($_POST['password']) && isset($_POST['confirmpassword']) && isset($_POST['birthdate']))
  69. {
  70.  
  71. // receiving the post params
  72. $password = $_POST['password'];
  73. $confirmpassword = $_POST['confirmpassword'];
  74. $birthdate = $_POST['birthdate'];
  75. //echo $_GET['elite_id'];
  76. // $elite_id=$_POST['elite_id'];
  77. // create a new user
  78. $user = $db->StoreEliteInfo($password,$confirmpassword,$birthdate);
  79. if ($user) {
  80. // user stored successfully
  81. $response["error"] = FALSE;
  82. $response["user"]["password"] = $user["password"];
  83. $response["user"]["confirmpassword"] = $user["confirmpassword"];
  84. $response["user"]["birthdate"] = $user["birthdate"];
  85. $response["user"]["elite_id"] = $user["elite_id"];
  86. echo json_encode($response);
  87. }
  88. else
  89. {
  90. // user failed to store
  91. $response["error"] = TRUE;
  92. $response["error_msg"] = "Unknown error occurred in registration!";
  93. echo json_encode($response);
  94. }
  95.  
  96. } else {
  97. $response["error"] = TRUE;
  98. $response["error_msg"] = "Required parameters (password,confirmpassword,birthdate) is missing!";
  99. echo json_encode($response);
  100. }
  101. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement