Похожие чаты

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 ответов

16 просмотров

Wrong group

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

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

Сообщение* в закодированном виде. То есть, просто сделать sendMessage?text=Привет бла-бла! не получится, надо в HEX переводить, и добавлять процент, типа такого: sendMessage?t...
КТ315
21
А случайно нет ли в паскале штатной возможности передать указатель и количество туда где array of в качестве аргумента?
zamtmn
25
@LGCYMan @JustinKKW Q/A List 1. this part confuses me on #8: "From there, a bridge between erc20 LGXY and erc20 LGXY will be out once that swap is closed." does this mean ...
Sig | LGCY | BattleVerse L1 | BitWin
1
Всем привет. Испытываю проблемы в работе БД, а именно огромного роста логов, такого характера: 024-05-16 18:39:07 +05 sentry sentry [unknown] 1050169 7-1 app-sentry01.corp.ru>...
Alexey
2
Anyone have any good learning material on how to do network analysis on cryptocurrency? Obviously monero is different story, but for Ethereum network for example. Thanks.
John Doe
13
Anyone here suffers from unexplained aural migraines, who would be up for talking for a bit? Doesn't *have* to be aural, but I am not asking about headaches, I mean actual mi...
Martin Rys
58
Хм. А телеграм апи работают через HTTP?
The Bird of Hermes
14
Did @Beeker really get banned? That's ridiculous. He's one of the few left here with half a brain and you might not always like his narrative @dgb_ycagel , but he often keeps ...
Leroy Gerrits
1
Почему Telegram пишет, что объект media не найден, хотя на самом деле я его передаю? Делаю на urllib, без зависимостей, так надо. Вызываю метод sendMediaGroup с таким JSON: ...
Alexey S
1
Ну раз я пока тут, задам пару глупых вопросов. Зачем писать на ассемблере если компилятор довольно умный, а ассемблер много времени занимает? В каких прикладных задачах сейчас...
Максим Рябцев
20
Карта сайта