mmosel Posted April 25, 2006 Share Posted April 25, 2006 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? Quote Link to comment https://forums.phpfreaks.com/topic/8321-use-php-to-post-and-then-load-page-posted-to/ Share on other sites More sharing options...
michaellunsford Posted April 25, 2006 Share Posted April 25, 2006 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 Link to comment https://forums.phpfreaks.com/topic/8321-use-php-to-post-and-then-load-page-posted-to/#findComment-30354 Share on other sites More sharing options...
mmosel Posted April 25, 2006 Author Share Posted April 25, 2006 [!--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. Quote Link to comment https://forums.phpfreaks.com/topic/8321-use-php-to-post-and-then-load-page-posted-to/#findComment-30367 Share on other sites More sharing options...
michaellunsford Posted April 25, 2006 Share Posted April 25, 2006 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 Link to comment https://forums.phpfreaks.com/topic/8321-use-php-to-post-and-then-load-page-posted-to/#findComment-30372 Share on other sites More sharing options...
mmosel Posted April 25, 2006 Author Share Posted April 25, 2006 [!--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... Quote Link to comment https://forums.phpfreaks.com/topic/8321-use-php-to-post-and-then-load-page-posted-to/#findComment-30404 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.