Jump to content


Photo

Use PHP to Post and then load page Posted to?


  • Please log in to reply
4 replies to this topic

#1 mmosel

mmosel
  • Members
  • PipPipPip
  • Advanced Member
  • 66 posts

Posted 25 April 2006 - 12:39 AM

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?

#2 michaellunsford

michaellunsford
  • Members
  • PipPipPip
  • Advanced Member
  • 1,023 posts
  • LocationLouisiana, USA

Posted 25 April 2006 - 12:59 AM

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?

#3 mmosel

mmosel
  • Members
  • PipPipPip
  • Advanced Member
  • 66 posts

Posted 25 April 2006 - 01:26 AM

[!--quoteo(post=368237:date=Apr 24 2006, 07:59 PM:name=michaellunsford)--][div class=\'quotetop\']QUOTE(michaellunsford @ Apr 24 2006, 07:59 PM) View Post[/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.

#4 michaellunsford

michaellunsford
  • Members
  • PipPipPip
  • Advanced Member
  • 1,023 posts
  • LocationLouisiana, USA

Posted 25 April 2006 - 01:40 AM

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.

#5 mmosel

mmosel
  • Members
  • PipPipPip
  • Advanced Member
  • 66 posts

Posted 25 April 2006 - 05:13 AM

[!--quoteo(post=368256:date=Apr 24 2006, 08:40 PM:name=michaellunsford)--][div class=\'quotetop\']QUOTE(michaellunsford @ Apr 24 2006, 08:40 PM) View Post[/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...







0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users