Jump to content

Use PHP to Post and then load page Posted to?


mmosel

Recommended Posts

I understand how fsockopen() works, and as far as I know, this is the only way to Post data to a page using PHP. However, when using a form submit, you get redirected to the page posted to. Is there a way using PHP to post data to a page AND have the page open as if posted to from a form?
CURL is probably the method of choice here, but I'm curious about the fsockopen thing. There is an fsockopen example on the PHP site talking about exactly what you're trying to do...
[a href=\"http://us2.php.net/fsockopen\" target=\"_blank\"]http://us2.php.net/fsockopen[/a]

It's pushing request headers that mimics a POST request. Have you seen that example?
[!--quoteo(post=368237:date=Apr 24 2006, 07:59 PM:name=michaellunsford)--][div class=\'quotetop\']QUOTE(michaellunsford @ Apr 24 2006, 07:59 PM) [snapback]368237[/snapback][/div][div class=\'quotemain\'][!--quotec--]
CURL is probably the method of choice here, but I'm curious about the fsockopen thing. There is an fsockopen example on the PHP site talking about exactly what you're trying to do...
[a href=\"http://us2.php.net/fsockopen\" target=\"_blank\"]http://us2.php.net/fsockopen[/a]

It's pushing request headers that mimics a POST request. Have you seen that example?
[/quote]

Hi, thanks. Yeah, I'm familar with posting data via fsockopen. The problem is that in a situation where you want to be redirected to the same URL that you're posting too. fsockopen is used to return a result to the same script. In the mean time, I'm going to use Javascript and auto submit a form to the new URL.
[!--quoteo(post=368256:date=Apr 24 2006, 08:40 PM:name=michaellunsford)--][div class=\'quotetop\']QUOTE(michaellunsford @ Apr 24 2006, 08:40 PM) [snapback]368256[/snapback][/div][div class=\'quotemain\'][!--quotec--]
if the form is doing a header redirect, you will either have to use curl (which has a FOLLOWLOCATION option), or if you get full headers back with fsockopen, check for the "Location:" they're redirecting you to.
[/quote]

Thanks Michael,

I'll look into the cURL option...


Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.