1 Star 1 Fork 0

AxxSabrina/基于PHP+Mysql的Cyperbunk2077未来车辆店管理系统设计与开发

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
deleteSingleItem.php 979 Bytes
一键复制 编辑 原始数据 按行查看 历史
AxxSabrina 提交于 2024-10-09 13:40 . 网站代码提交 不附带素材
<?php
session_start();
$servername = "localhost";
$username = "root";
$password = "root";
$dbname = "cyberpunk";
$conn = new mysqli($servername, $username, $password, $dbname);
if ($conn->connect_error) {
die("连接数据库失败: " . $conn->connect_error);
}
// 检查用户是否已登录
if (!isset($_SESSION['id'])) {
http_response_code(401);
echo json_encode(['error' => '用户未登录']);
exit;
}
$user_id = $_SESSION['id'];
$car_id = $_POST['car_id'];
$sql = "DELETE FROM user_cart WHERE user_id=? AND vehicle_id=?";
$stmt = $conn->prepare($sql);
if (!$stmt) {
http_response_code(500);
echo json_encode(['error' => '预处理 SQL 语句失败: ' . $conn->error]);
exit;
}
$stmt->bind_param("ii", $user_id, $car_id);
$stmt->execute();
$affected_rows = $stmt->affected_rows;
$stmt->close();
$conn->close();
$response = ['success' => ($affected_rows > 0)];
header('Content-Type: application/json');
echo json_encode($response);
exit;
?>
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
HTML
1
https://gitee.com/axxsabrina/Cyberpunk2077_Future_Vehicle_Store.git
git@gitee.com:axxsabrina/Cyberpunk2077_Future_Vehicle_Store.git
axxsabrina
Cyberpunk2077_Future_Vehicle_Store
基于PHP+Mysql的Cyperbunk2077未来车辆店管理系统设计与开发
master

搜索帮助