Welcome to WebmasterWorld Guest from

Forum Moderators: coopster & jatar k

Message Too Old, No Replies

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

5:13 am on Feb 26, 2011 (gmt 0)

New User

5+ Year Member

joined:Nov 14, 2010
posts: 8
votes: 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.
7:59 am on Feb 26, 2011 (gmt 0)

Preferred Member

5+ Year Member

joined:Aug 18, 2008
votes: 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>';

2:37 pm on Feb 26, 2011 (gmt 0)

New User

5+ Year Member

joined:Nov 14, 2010
posts: 8
votes: 0

Thank you!

Join The Conversation

Moderators and Top Contributors

Hot Threads This Week

Featured Threads

Free SEO Tools

Hire Expert Members