Skip to main content
Inspiring
March 23, 2012
解決済み

Header () Function

  • March 23, 2012
  • 返信数 1.
  • 532 ビュー

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.

このトピックへの返信は締め切られました。
解決に役立った回答 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;

返信数 1

nicko2作成者解決!
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'];