homepage Welcome to WebmasterWorld Guest from 54.227.20.250
register, free tools, login, search, pro membership, help, library, announcements, recent posts, open posts,
Pubcon Platinum Sponsor 2014
Home / Forums Index / Code, Content, and Presentation / PHP Server Side Scripting
Forum Library, Charter, Moderators: coopster & jatar k

PHP Server Side Scripting Forum

    
Passing entire URL as a Variable
CliffR

10+ Year Member



 
Msg#: 3015516 posted 7:46 am on Jul 20, 2006 (gmt 0)

I'm having trouble searching for this because I keep getting search results that have to do with passing variables through a URL. I have no problem doing that. I need to pass an entire URL to a PHP script like:

[mysite.com...]

The problem I'm having is when someothersite.com has a long query string and some of the variables get truncated. My php knowledge is limited so I'm using

$url = $_GET['newsite'];

to grab the URL, but it doesn't work when the new URL has multiple variables. How do I keep the entire URL intact as it's passed to my script?

 

Scally_Ally

5+ Year Member



 
Msg#: 3015516 posted 8:22 am on Jul 20, 2006 (gmt 0)

could you not replace all the ampersands in the variable newsite just before you send it and then convert i back after that? something like.

$newsite = [someothersite.com...]
$newsite = str_replace("&", "[MyAmp]", $newsite);
[mysite.com...]

then on the page that receives just reverse it..
$newsite = $_GET["newsite"];
$newsite = str_replace("[MyAmp]", "&", $newsite);

Gibisan

10+ Year Member



 
Msg#: 3015516 posted 8:36 am on Jul 20, 2006 (gmt 0)

You could also use urlencode()

$newsite = urlencode("http://www.someothersite.com/page.php?var1=1&var2=2");
[mysite.com...]

In go.php
$newsite = $_GET["newsite"];
$newsite will be "http://www.someothersite.com/page.php?var1=1&var2=2" - no need to change.

Global Options:
 top home search open messages active posts  
 

Home / Forums Index / Code, Content, and Presentation / PHP Server Side Scripting
rss feed

All trademarks and copyrights held by respective owners. Member comments are owned by the poster.
Home ¦ Free Tools ¦ Terms of Service ¦ Privacy Policy ¦ Report Problem ¦ About ¦ Library ¦ Newsletter
WebmasterWorld is a Developer Shed Community owned by Jim Boykin.
© Webmaster World 1996-2014 all rights reserved