Skip to main content
Inspiring
March 23, 2012
Answered

Header () Function

  • March 23, 2012
  • 2 replies
  • 533 views

Hi All

I want to use the header function to redirect to another page after information from a form has been submitted and processed. I can do this without any problem, but I need to pass a variable that is needed by the destination page with the header information.

I trying to do it using the code below, and it's the part in orange that's causing the trouble!

if ($done || !isset($gallery_id)) {

header('Location: http://localhost/photo_gallery/admin/year_view.php?year_id="$year_id"');

exit;

}

What is the correct syntax to enable me to pass the variable? Any ideas would be greatly appreciated.

Thanks.

This topic is closed to new replies. Start a new post to keep the conversation going.
Correct answer nicko2

Found the answer.

if ($done || !isset($gallery_id)) {

header('Location: http://localhost/photo_gallery/admin/year_view.php?year_id='.$_GET['year_id']);

exit;

2 replies

nicko2AuthorCorrect answer
Inspiring
March 23, 2012

Found the answer.

if ($done || !isset($gallery_id)) {

header('Location: http://localhost/photo_gallery/admin/year_view.php?year_id='.$_GET['year_id']);

exit;

Rob Hecker2
Legend
March 23, 2012

Niko,

your first example probably didn't work if you did not convert your GET variable to a local variable, like this:

$year_id = is_int($_GET['year_id'];