db = mysqli_connect("localhost", "root", "1q2w3e", "zepheus"); } function make_game_acc($name, $password, $admin = 0) { $stmt = $this->db->prepare("SELECT * FROM accounts WHERE Username = ?"); $stmt->bind_param("s", $name); $stmt->execute(); $stmt->store_result(); if ($stmt->num_rows != 0) { return 2; //Name already used } $stmt = $this->db->prepare("INSERT INTO accounts (`Username`, `Password`, `Admin`) VALUES (?, ?, ?)"); $stmt->bind_param("ssi", $name, $password, $admin); $stmt->execute(); return 1; } } $zepheus = new zepheus; if (isset($_POST['submit'])) { //register the player. //make our own checks for data validity. In terms of the code, it will take anything it's given (injections impossible) if ($_POST['password'] == $_POST['password2']) { $create = $zepheus->make_game_acc("$_POST[username]", "$_POST[password]", "$_POST[username]", 1, "$_SERVER[REMOTE_ADDR]"); if ($create == 2) { $error = "
| Password: | |
| Repeat Password: | |