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

Header () Function

Community Beginner ,
Mar 23, 2012 Mar 23, 2012

Copy link to clipboard

Copied

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

Views

464
Translate

Report

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;

Votes

Translate
Community Beginner ,
Mar 23, 2012 Mar 23, 2012

Copy link to clipboard

Copied

Found the answer.

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

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

exit;

Votes

Translate

Report

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
Guru ,
Mar 23, 2012 Mar 23, 2012

Copy link to clipboard

Copied

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

Votes

Translate

Report

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