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.
Found the answer.
if ($done || !isset($gallery_id)) {
header('Location: http://localhost/photo_gallery/admin/year_view.php?year_id='.$_GET['year_id']);
exit;
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;
Copy link to clipboard
Copied
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'];