0){ return true; }else { return false; } } function newAddition() { global $con, $username,$jumble; $statement = mysqli_prepare($con, "INSERT INTO game_times (username,jumble) VALUES (?, ?)"); mysqli_stmt_bind_param($statement, "si", $username,$jumble); mysqli_stmt_execute($statement); mysqli_stmt_store_result($statement); mysqli_stmt_close($statement); } function oldAddition(){ global $con, $username,$jumble; $statement = mysqli_prepare($con, "UPDATE game_times SET jumble = ? WHERE username = ?"); mysqli_stmt_bind_param($statement, "is",$jumble,$username); mysqli_stmt_execute($statement); mysqli_stmt_store_result($statement); mysqli_stmt_close($statement); } $response = array(); $response["success"] = false; if(usernameExists()){ oldAddition(); $response["success"] = true; } else{ newAddition(); $response["success"] = true; } echo json_encode($response); ?>