Rossputin Posted January 8, 2011 Share Posted January 8, 2011 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!!! Quote Link to comment Share on other sites More sharing options...
hyster Posted January 8, 2011 Share Posted January 8, 2011 try from header( 'Location: http://site2.com/dir/admin/?page=$passpage&id=$passid'); to header( 'Location: http://site2.com/dir/admin/?page=passpage&id=passid'); remove $ from url Quote Link to comment Share on other sites More sharing options...
Rossputin Posted January 8, 2011 Author Share Posted January 8, 2011 unfortunately, that didn't work. gave me this (literal) link: http://site2.com/dir/admin/?page=passpage&id=passid Quote Link to comment Share on other sites More sharing options...
Pikachu2000 Posted January 8, 2011 Share Posted January 8, 2011 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"); Quote Link to comment Share on other sites More sharing options...
Rossputin Posted January 8, 2011 Author Share Posted January 8, 2011 Thanks, that worked (after I removed GLOBAL$)!!! Thanks so much for your help! Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.