Похожие чаты

Please someone help is not sending it to my database

I try it morethan 20 times 😭😭😭😭
<?php

$dbServer = "localhost";
$dbUsername = "airfashi_sani20";
$dbPassword = "muhammad@20";
$dbName = "airfashi_fashion";

// Establish a database connection
$conn = new mysqli($dbServer, $dbUsername, $dbPassword, $dbName);

if ($conn->connect_error) {
die("Connection failed: " . $conn->connect_error);
}

// Check if it's a POST request
if ($_SERVER['REQUEST_METHOD'] === 'POST') {
// Check if POST data is set
if (isset($_POST['reference'], $_POST['total'], $_POST['fullName'], $_POST['address'], $_POST['phoneNumber'], $_POST['deliveryType'], $_POST['productId'], $_POST['email'])) {
// Retrieve data from the POST request
$reference = $_POST['reference'];
$total = $_POST['total'];
$fullName = $_POST['fullName'];
$address = $_POST['address'];
$phoneNumber = $_POST['phoneNumber'];
$deliveryType = $_POST['deliveryType'];
$productId = $_POST['productId'];
$email = $_POST['email'];

// Use Prepared Statements to prevent SQL injection
$sql = "INSERT INTO payments (reference, total, full_name, address, phone_number, delivery_type, product_id, email) VALUES (?, ?, ?, ?, ?, ?, ?, ?)";
$stmt = $conn->prepare($sql);
$stmt->bind_param("ssssssss", $reference, $total, $fullName, $address, $phoneNumber, $deliveryType, $productId, $email);

// Execute the query
if ($stmt->execute()) {
$response = array('status' => 'success', 'message' => 'Payment details inserted successfully');
} else {
$response = array('status' => 'error', 'message' => 'Error inserting payment details: ' . $stmt->error);
}

// Close the database connection
$stmt->close();
$conn->close();
} else {
$response = array('status' => 'error', 'message' => 'Incomplete POST data');
}

// Send the response back to the JavaScript code
echo json_encode($response);
}

?>

1 ответов

50 просмотров

Wrong group

Похожие вопросы

Обсуждают сегодня

Господа, а что сейчас вообще с рынком труда на делфи происходит? Какова ситуация?
Rꙮman Yankꙮvsky
29
А вообще, что может смущать в самой Julia - бы сказал, что нет единого стандартного подхода по многим моментам, поэтому многое выглядит как "хаки" и произвол. Короче говоря, с...
Viktor G.
2
@Benzenoid can you tell me the easiest, and safest way to bu.y HEX now?
Živa Žena
20
This is a question from my wife who make a fortune with memes 😂😂 About the Migration and Tokens: 1. How will the old tokens be migrated to the new $LGCYX network? What is th...
🍿 °anton°
2
30500 за редактор? )
Владимир
47
а через ESC-код ?
Alexey Kulakov
29
What is the Dex situation? Agora team started with the Pnetwork for their dex which helped them both with integration. It’s completed but as you can see from the Pnetwork ann...
Ben
1
Гайс, вопрос для разносторонее развитых: читаю стрим с юарта, нада выделять с него фреймы с определенной структурой, если ли чо готовое, или долбаться с ринг буффером? нада у...
Vitaly
9
Anyone knows where there are some instructions or discort about failed bridge transactions ?
Jochem
21
@lozuk how do I get my phex copies of my ehex from a atomic wallet, to move to my rabby?
Justfrontin 👀
11
Карта сайта