Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- $connect = mysqli_connect("localhost", "id3199319_kbcmaster", "xplayers2305", "id3199319_kbcregistration");
- $name = $_POST["name"];
- $time = $_POST["time"];
- $id = $_POST["id"];
- function registerUser() {
- global $connect, $name, $time, $id;
- $statement = mysqli_prepare($connect, "INSERT INTO registration (name, time, id) VALUES (?, ?, ?)");
- mysqli_stmt_bind_param($statement, "sss", $name, $time, $id);
- mysqli_stmt_execute($statement);
- mysqli_stmt_close($statement);
- }
- function nameAvailable() {
- global $connect, $id;
- $statement = mysqli_prepare($connect, "SELECT * FROM registration WHERE id = ?");
- mysqli_stmt_bind_param($statement, "s", $id);
- mysqli_stmt_execute($statement);
- mysqli_stmt_store_result($statement);
- $count = mysqli_stmt_num_rows($statement);
- mysqli_stmt_close($statement);
- if ($count < 1){
- return true;
- }else {
- // Logic needs to be here as per requirement maybe
- return false;
- }
- }
- $response = array();
- $response["success"] = false;
- if (nameAvailable()){
- registerUser();
- $response["success"] = true;
- }
- echo json_encode($response);
- ?>
Add Comment
Please, Sign In to add comment