Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- include_once "mmoconnection.php";
- $mydata = json_decode(file_get_contents('php://input'));
- $accountname = $mydata ->accountname;
- $username = $mydata ->username;
- $accountpassword = $mydata ->accountpassword;
- if ($stmt = $conn->prepare("SELECT * FROM `users` WHERE accountname = ? "))
- {
- $stmt->bind_param("s", $accountname);
- $stmt->execute();
- if ($stmt->fetch()) echo json_encode(array('status'=>'This account name is unavailable')); // IF ACOUNT NAME IS TAKEN THEN BAD STATUS
- else{
- if ($stmt = $conn->prepare("SELECT * FROM `characters` WHERE username = ? "))
- {
- $stmt->bind_param("s", $username);
- $stmt->execute();
- if ($stmt->fetch()) echo json_encode(array('status'=>'This user name is unavailable')); // IF USER NAME IS TAKEN THEN BAD STATUS
- else {
- // CREATE ACCOUNT
- $hash = password_hash($accountpassword, PASSWORD_DEFAULT);
- $stmt = $conn->prepare("INSERT INTO `users` VALUES (NULL, ?, ?)");
- $stmt->bind_param("ss", $accountname, $hash);
- $stmt->execute();
- $stmt = $conn->prepare("INSERT INTO `characters` VALUES (NULL, NULL, ?, NULL)");
- $stmt->bind_param("s", $username);
- $stmt->execute();
- $stmt->close();
- echo json_encode(array('status'=>'OK' ));
- }
- }
- }
- }
- ///'EXPLAIN SELECT * FROM `characters`';
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement