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
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");

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.