20){ $username_err = "Username must be under 20 characters."; } else{ // Prepare a select statement $sql = "SELECT id FROM users WHERE LOWER(username) = ?"; if($stmt = mysqli_prepare($link, $sql)){ // Bind variables to the prepared statement as parameters mysqli_stmt_bind_param($stmt, "s", $param_username); // Set parameters $param_username = trim(strtolower($_POST["username"])); // die($param_username); // Attempt to execute the prepared statement if(mysqli_stmt_execute($stmt)){ /* store result */ mysqli_stmt_store_result($stmt); if(mysqli_stmt_num_rows($stmt) != 0){ $username_err = "This username is already taken."; } else{ $username = trim($_POST["username"]); } } else{ echo "Oops! Something went wrong. Please try again later."; } // Close statement mysqli_stmt_close($stmt); } } // Validate password if(empty(trim($_POST["password"]))){ $password_err = "Please enter a password."; } elseif(strlen(trim($_POST["password"])) < 4){ $password_err = "Password must have atleast 4 characters."; } else{ $password = trim($_POST["password"]); } // Validate confirm password if(empty(trim($_POST["confirm_password"]))){ $confirm_password_err = "Please confirm password."; } else{ $confirm_password = trim($_POST["confirm_password"]); if(empty($password_err) && ($password != $confirm_password)){ $confirm_password_err = "Password did not match."; } } // Check input errors before inserting in database if(empty($username_err) && empty($password_err) && empty($confirm_password_err)){ // Chat mode if ($_POST['chatmode'] == 'true'){ $chat = "1"; }else{ $chat = "0"; } // Verify age if ($_POST['age'] == 'under13'){ $age = "1"; $chat = "1"; // override user's chat choice to the supersafe chat because coppa }else{ $age = "0"; } // Prepare an insert statement $sql = "INSERT INTO users (username, password, age, chatMode) VALUES (?, ?, ?, ?)"; if($stmt = mysqli_prepare($link, $sql)){ // Bind variables to the prepared statement as parameters mysqli_stmt_bind_param($stmt, "ssss", $param_username, $param_password, $param_age, $param_chat); // Set parameters $param_username = $username; $param_password = password_hash($password, PASSWORD_DEFAULT); // Creates a password hash $param_age = $age; $param_chat = $chat; $key = $_POST['key']; // $invitekeyq = mysqli_query($link, "SELECT * FROM invitekeys WHERE invkey='$key'") or die(mysqli_error($link)); // $getkeydata = mysqli_fetch_assoc($invitekeyq); if ($_POST['key'] == null) { // die("enter an key"); } if ($_POST['key'] !== $getkeydata['invkey']) { // die("invalid invite key"); } if ($getkeydata['isredeemed'] == "yes") { // die("key is already redeemed"); } // Attempt to execute the prepared statement if(mysqli_stmt_execute($stmt)){ session_start(); $_SESSION["loggedin"] = true; $_SESSION["username"] = $username; $user = mysqli_fetch_assoc(mysqli_query($link, "SELECT * FROM users WHERE username = '".addslashes($username)."'")); $_SESSION["id"] = $user['id']; header("location: /api/render.php?returnUrl=".$returnurl); } else{ echo "Oops! Something went wrong. Please try again later."; } // Close statement mysqli_stmt_close($stmt); } } // Close connection mysqli_close($link); } ?>
If you just need to login, go to the Login page.
If you have already registered but you still need to download the game installer, go directly to download.
Registration does not provide any guarantees of service. See our Terms of Service and Licensing Agreement for details.
=$sitename ?> will not share your email address with 3rd parties. See our Privacy Policy for details.