【发布时间】:2018-05-28 17:25:28
【问题描述】:
嗨,伙计们试图找到错误页面未更改为 index.php。
不重定向到着陆页一切正常。
从数据库中删除记录,删除是/否的页面也可以
<?php
// Process delete operation after confirmation
if(isset($_POST["ID"]) && !empty($_POST["ID"])){
// Include config file
require_once 'config.php';
// Prepare a select statement
$sql = "DELETE FROM cv WHERE ID = ?";
if($stmt = mysqli_prepare($link,$sql)){
// Bind variables to the prepared statement as parameters
mysqli_stmt_bind_param($stmt, "i", $param_ID);
// Set parameters
$param_ID = trim($_POST["ID"]);
// Attempt to execute the prepared statement
if(mysqli_stmt_execute($stmt)){
// Records deleted successfully. Redirect to landing page
header('Location:index.php');
exit;
}else{
echo "Oops! Something went wrong. Please try again later.";
}
}
// Close statement
mysqli_stmt_close($stmt);
// Close connection
mysqli_close($link);
} else{
// Check existence of ID parameter
if(empty(trim($_GET["ID"]))){
// URL doesn't contain ID parameter. Redirect to error page
header("location: error.php");
exit();
}
}
?>
任何帮助都会很棒。
警告:无法修改标头信息 - 第 26 行 /storage/public_html/crudbd/delete.php 中的标头(输出开始于 /storage/public_html/crudbd/config.php:31)
【问题讨论】:
-
你试过绝对路径吗?
-
@Niels 他做了
if($stmt = mysqli_prepare($link,$sql)) -
@Niels 他正在分配而不是比较
-
@Niels 不,没有
==。if ($something = somefunction())和$something = somefunction(); if($something)是一回事
标签: php