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!!! Link to comment https://forums.phpfreaks.com/topic/223778-passing-parameter-within-redirect/ 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 Link to comment https://forums.phpfreaks.com/topic/223778-passing-parameter-within-redirect/#findComment-1156670 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 Link to comment https://forums.phpfreaks.com/topic/223778-passing-parameter-within-redirect/#findComment-1156671 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"); Link to comment https://forums.phpfreaks.com/topic/223778-passing-parameter-within-redirect/#findComment-1156672 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! Link to comment https://forums.phpfreaks.com/topic/223778-passing-parameter-within-redirect/#findComment-1156674 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.