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

PHP Server Side Scripting Forum

How do I send data using GET Method without the user following?

Msg#: 4272806 posted 5:13 am on Feb 26, 2011 (gmt 0)

I hope this is the right place for this question, but if it's not, my apologies up front.

Basically what I'm trying to do is pass data using GET METHOD to an external file/page while directing the user somewhere else. The chronology is as follows:

1. User submits web form.
2. Form is processed by a PHP script on the same site using POST METHOD.
3. After data is run through some logic filters, it is inserted into our local DB.
4. However, before sending the user on to the thank-you.php page, we need to send certain data to an external page/file that is managed by an external client site. They want that data sent via GET METHOD (eg. [sample.com...]

With my limited experience in PHP, I would only know how to send this on using the header() function. I don't know how to pass data using GET METHOD without sending the user as well. After the user submits the form, they need to end up on the thank-you.php page. Not on some external site. I think this can be done with AJAX, but I don't know AJAX and if there's a way I can do it with PHP server-side, I'd prefer that.

Any help or advice is greatly appreciated.



5+ Year Member

Msg#: 4272806 posted 7:59 am on Feb 26, 2011 (gmt 0)

With GET, it's as simple as directly accessing the sites file, with or without any url variables (who's values should be properly urlencode'd if possibly containing special characters):

$query = 'what are widgets anyhow?';

$url = 'http://www.google.com/search?hl=en&q='.urlencode($query);

$f = @file_get_contents($url);

if ($f !== false) { //you know you've reached their file and they received your GET request
echo $f;
} else {
echo '<pre>';
echo '</pre>';



Msg#: 4272806 posted 2:37 pm on Feb 26, 2011 (gmt 0)

Thank you!

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