0

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?

7
  • impossible to answer; not enough code. Otherwise, use isset() or !empty() in a conditional. If this is db related, could be an issue there too. Commented Apr 15, 2016 at 23:17
  • Please provide more code. Commented Apr 15, 2016 at 23:18
  • have a load of code just wanted to keep it simple. would it be a good idea to store the variable for shifts_id in sessions and dnt unset it? Commented Apr 15, 2016 at 23:18
  • anything to do with your previous last question? stackoverflow.com/q/36550004 as for your last comment; sure, why not. Commented Apr 15, 2016 at 23:19
  • No nothing to do with a modal, let me post more code ... Commented Apr 15, 2016 at 23:20

1 Answer 1

2

Simply pass the parameter on again in the header()

header("location:admin_shifts_view.php?id=$user_id");
Sign up to request clarification or add additional context in comments.

3 Comments

should be named id instead of userid here (look at admin_shifts_view.php), and I think he wants the $shifts_id to be passed along
Woops you are absolutely right. Got a bit lost there for a sec, its gone midnight here
It always is when you know the answer

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.