Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

Header () Function

Community Beginner ,
Mar 23, 2012 Mar 23, 2012

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.

TOPICS
Server side applications
557
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 1 Correct answer

Community Beginner , Mar 23, 2012 Mar 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;

Translate
Community Beginner ,
Mar 23, 2012 Mar 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;

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Mentor ,
Mar 23, 2012 Mar 23, 2012
LATEST

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'];

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines