prepare("SELECT COUNT(*) FROM orders WHERE OrderID = ?"); $stmt->bind_param("s", $newOrderID); $stmt->execute(); $stmt->bind_result($count); $stmt->fetch(); $stmt->close(); return $count > 0; } do { $newOrderID = generateOrderID(); } while (isOrderIDExists($conn, $newOrderID)); // Check if the combination of Place_Num and Dates already exists $checkSql = "SELECT * FROM orders WHERE Place_Num = '$Place' AND Dates = '$date'"; $checkResult = mysqli_query($conn, $checkSql); if(mysqli_num_rows($checkResult) > 0) { // Combination already exists, show error message echo ""; echo ""; exit(); } else{ // Insert into user table $sql = "INSERT INTO orders (OrderID, Place_Num, Renter_ID, Admin_ID, License, Dates, Category_Type, Approve_Status, Checks_Status, Pay_Status) VALUES ('".$newOrderID."','".$Place."', '".$renterId."', '".$adminId."', '".$license."', '".$date."', '".$category."','".$approve."','".$check."','".$pay."')"; $column = mysqli_query($conn, $sql); if($column != 0) { echo ""; echo ""; exit(); } else { echo ""; echo ""; exit(); } } mysqli_close($conn); //data security purposes } ?>