3 回答
TA贡献1793条经验 获得超6个赞
你提到:
虽然在view_task.php时得到错误,但数据保存成功!
基于此,我可以假设您从仪表板输入了view_task.php.php没有任何错误
错误仅在您单击“保存”按钮后发生。
所以,并且必须成功发送到update_task_name.phptask_namereport_id
但是,当您尝试重定向回task_view.php时:
header("Location: view_task.php");您没有view_task.php,并导致了您在问题中提到的错误report_id
所以,这是我的答案,在你的update_task_name.php
替换以下内容:
header("Location: view_task.php");与此:
header("view_task.php?report_id=".$_POST['report_id'])TA贡献1853条经验 获得超9个赞
这一切都过于复杂,因为它非常简单:
/* initialize variables before already */
$report_id = -1;
$task_name = '';
/* check if the $_GET has a numerical report_id */
if(isset($_GET['report_id']) && is_numeric($_GET['report_id'])) {
/* then dare to access $_GET['report_id'] */
$report_id = $_GET['report_id']; //line 7
$sql = "SELECT * FROM ot_report WHERE report_id = :report_id";
$query = $conn->prepare($sql);
$query->execute(array(':report_id' => $report_id));
while($row = $query->fetch(PDO::FETCH_ASSOC)){
$task_name = $row["task_name"];
}
}
...
TA贡献1859条经验 获得超6个赞
你的错误是这个...
只需使用有效的report_id访问您的页面
localhost/project_name/view_task/1
您可能没有在 URL 中证明 id,因此view_task查询本身不起作用,因为它没有从 GET 方法的 URL 获取 id。
- 3 回答
- 0 关注
- 171 浏览
添加回答
举报
