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?
Link to comment
Share on other sites

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?
Link to comment
Share on other sites

[!--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.
Link to comment
Share on other sites

[!--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...


Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.