<?php header("Access-Control-Allow-Origin: *"); $ecodedata = $_POST["postdata"]; // echo "server say::".($ecodedata); //base64_decode $b= json_decode ($ecodedata); $v= $b->v; $w= $b->w; $x= $b->x; $y= $b->y; $z= $b->z; require_once "config.php"; $sql = "SELECT id FROM users WHERE username = '".$x."'"; //check data if($result = mysqli_query($link, $sql)){ if(mysqli_num_rows($result) > 0){ $have="yes"; while($row = mysqli_fetch_array($result)){ } mysqli_free_result($result); } else{ $rest="No records were found";} } else{ $rest="ERROR: Could not able to execute $sql. " . mysqli_error($link); } if ($have) { echo "Sorry:[$x] already taken";} if (!$have) { // echo "start create user"; $sql = "SELECT id FROM users WHERE username = '".$x."'"; $sql = "INSERT INTO users (username, email, code, password,company,businesstype) VALUES (?, ? ,?,?,?,?)"; if($stmt = mysqli_prepare($link, $sql)){ // Bind variables to the prepared statement as parameters mysqli_stmt_bind_param($stmt, "sssssi", $param_username,$param_email,$param_code, $param_password,$param_company,$param_businesstype); // Set parameters $param_username = $x; $param_email=$y; $param_code="1"; $param_company=$w; $param_businesstype=$v; //$param_password = password_hash($password, PASSWORD_DEFAULT); // Creates a password hash $param_password =$z; // Attempt to execute the prepared statement if(mysqli_stmt_execute($stmt)){ // Redirect to login page // header("location: login.php"); echo "OK";// created user" .$param_company; } else{ $rest="ERROR: Could not able to execute $sql. " . mysqli_error($link); echo "Err$rest."; } // Close statement mysqli_stmt_close($stmt); } } ?>
Edit file:v_ius.php2245