Reputation: 135
I have a link in a table that has an id that is passed to another page
admin_shifts.php
<a href=admin_shifts_view.php?id=1>view</a>
I get this value in the second page and use it to create a table from sql data
admin_shifts_view.php
$shifts_id = $_GET['id']
I click a button to delete that shift which takes me to ...
<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");
So when I redirect to admin_shifts_view.php I get an Undefined Index error. Any suggestions?
Upvotes: 0
Views: 63
Reputation: 94682
Simply pass the parameter on again in the header()
header("location:admin_shifts_view.php?id=$user_id");
Upvotes: 2