我在表中有一个链接,其ID传递给另一个页面
admin_shifts.php
<a href=admin_shifts_view.php?id=1>view</a>
我在第二页中获取此值并使用它从sql数据
创建表admin_shifts_view.php
$shifts_id = $_GET['id']
我点击一个按钮删除那个转移到我...
<a href=delete_from_shift.php?userid=" . $user_id ."&shiftid=" .$shift_id.">Remove</a>
delete_from_shift.php
if(isset($_GET['userid'])){
$user_id = $_GET['userid'];
$shifts_id = $_GET['shiftid'];
$delete_sql = "DELETE FROM user_shifts WHERE user_id=" . $user_id . " AND shifts_id=" .$shifts_id;
$delete_result = $database->query($delete_sql);
$deleted = "<div class='alert alert-success' role='alert'>Employee successfully removed</div>";
}else{
$deleted = "<div class='alert alert-danger' role='alert'>Problem removing employee at this time</div>";
}
$_SESSION['delete_user'] = $deleted;
header("location:admin_shifts_view.php");
因此,当我重定向到admin_shifts_view.php时,我收到一个未定义的索引错误。有什么建议吗?
答案 0 :(得分:3)
只需在header()
header("location:admin_shifts_view.php?id=$user_id");