Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public function StoreInfo($password,$confirmpassword,$birthdate)
- {
- //$elite_id = mysql_insert_id();
- //$date = date('YYYY-MM-DD');
- $stmt = $this->conn->prepare("INSERT INTO ibeInsert(password,confirmpassword,birthdate,elite_id) VALUES(?, ?, ?,LAST_INSERT_ID())");
- $stmt->bind_param("sss", $password, $confirmpassword, $birthdate);
- $result = $stmt->execute();
- $stmt->close();
- if ($result) {
- $stmt = $this->conn->prepare("SELECT password, confirmpassword,birthdate,elite_id FROM ibeInsert");
- $stmt->execute();
- $stmt-> bind_result($token2,$token3,$token4,$token1);
- while ( $stmt-> fetch() ) {
- $user["password"] = $token2;
- $user["confirmpassword"]=$token3;
- $user["birthdate"] = $token4;
- $user["elite_id"]=$token1;
- }
- $stmt->close();
- return $user;
- } else {
- return false;
- }
- }
- //for gender country city
- public function StoreEliteInfoTo($gender,$country,$city)
- {
- // $this->conn;
- // $elite_id = mysql_insert_id();
- $stmt = $this->conn->prepare("INSERT INTO ibeInsert(gender,country,city,elite_id) VALUES(?, ?, ?, LAST_INSERT_ID())");
- $stmt->bind_param("sss", $gender, $country, $city);
- $result = $stmt->execute();
- $stmt->close();
- if ($result) {
- $stmt = $this->conn->prepare("SELECT gender, country,city,elite_id FROM ibeInsert");
- $stmt->execute();
- $stmt-> bind_result($token2,$token3,$token4,$token1);
- while ( $stmt-> fetch() ) {
- $user["gender"] = $token2;
- $user["country"]=$token3;
- $user["city"] = $token4;
- $user["elite_id"]=$token1;
- }
- $stmt->close();
- return $user;
- } else {
- return false;
- }
- }
- //call function
- <?php
- require_once 'update_user_info.php';
- $db = new update_user_info();
- // json response array
- $response = array("error" => FALSE);
- if (isset($_POST['password']) && isset($_POST['confirmpassword']) && isset($_POST['birthdate']))
- {
- // receiving the post params
- $password = $_POST['password'];
- $confirmpassword = $_POST['confirmpassword'];
- $birthdate = $_POST['birthdate'];
- //echo $_GET['elite_id'];
- // $elite_id=$_POST['elite_id'];
- // create a new user
- $user = $db->StoreEliteInfo($password,$confirmpassword,$birthdate);
- if ($user) {
- // user stored successfully
- $response["error"] = FALSE;
- $response["user"]["password"] = $user["password"];
- $response["user"]["confirmpassword"] = $user["confirmpassword"];
- $response["user"]["birthdate"] = $user["birthdate"];
- $response["user"]["elite_id"] = $user["elite_id"];
- echo json_encode($response);
- }
- else
- {
- // user failed to store
- $response["error"] = TRUE;
- $response["error_msg"] = "Unknown error occurred in registration!";
- echo json_encode($response);
- }
- } else {
- $response["error"] = TRUE;
- $response["error_msg"] = "Required parameters (password,confirmpassword,birthdate) is missing!";
- echo json_encode($response);
- }
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement