Jump to content

Passing parameter within redirect


Rossputin

Recommended Posts

Hello all,

 

I'm an absolute Newbie to PHP.  I'm struggling with a problem that I think is extremely basic to you experts but I just can't get it to work.

 

In short, I have an application that has a link that goes to:

 

Site1/dir/admin?id=(text)&page=(number)

 

I want to redirect to a link that's identical except it's Site2 at the beginning instead of Site 1.

 

What I've attempted so far is this:

 

<?php

 

$GLOBALS[$passid]=$_GET['id'];

$GLOBALS[$passpage]=$_GET['page'];

 

  header( 'Location: http://site2.com/dir/admin/?page=$passpage&id=$passid');

?>

 

But it just redirects to

http://site2.com/dir/admin/?page=$passpage&id=$passid

(with all of that text being literally what is in the URL, not the variable values)

 

I have a feeling I'm doing something small but very basic wrong.

 

The $GLOBALS thing was an afterthought.  Outcome is the same with or without that.

 

Any help much appreciated!!!

Link to comment
https://forums.phpfreaks.com/topic/223778-passing-parameter-within-redirect/
Share on other sites

If you're trying to get the values of $passpage and $passid into the URL string, you can't use them within single quotes. Variables are not interpolated when in a single quoted string. Just change them to double quotes and you should be good to go (assuming the variables have values, that is).

 

header( "Location: http://site2.com/dir/admin/?page=$passpage&id=$passid");

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.