|
|||||||
| PHP Discussion and technical support for using and deploying PHP based websites. |
![]() |
|
|
Thread Tools | Rate Thread | Display Modes |
|
#1
|
||||
|
||||
|
http_post - example needed
I'm stepping out my comfort zone a bit here...
I want to use http_post() to post a value to a supplier's server. I've looked at the documentation on php, and am not sure I fully understand it. I'm hoping someone here could give me a quick example of how to use http_post to send the following; Field name: test Value: "Y" Field name: ref Value :1234546 Target url: www.testit.com/script.php I don't want to draw the form in html and then send it... this is an automated response to my supplier's post to me. Thanks CTB
__________________
Oh Lord, please help me be the person my dog thinks I am. |
|
#2
|
||||
|
||||
|
Do you have the PECL HTTP extension installed? If so, you could use the http_post_data() function. If not, you could use the Curl functions, if you have the Curl extension installed.
__________________
"Please give us a simple answer, so that we don't have to think, because if we think, we might find answers that don't fit the way we want the world to be." ~ Terry Pratchett in Nation Kindle Minds (blog about Amazon Kindle) |
|
#3
|
||||
|
||||
|
Doesn't look like pecl is installed.
http_post_data() is probably the way to go, and I've looked at the php manual but my brain is crying out for an example because I'm not sure how to properly construct PHP Code:
__________________
Oh Lord, please help me be the person my dog thinks I am. |
|
#4
|
||||
|
||||
|
Looks like the http_post_fields() might be better (still requires the PECL HTTP extension, though):
PHP Code:
__________________
"Please give us a simple answer, so that we don't have to think, because if we think, we might find answers that don't fit the way we want the world to be." ~ Terry Pratchett in Nation Kindle Minds (blog about Amazon Kindle) |
|
#5
|
||||
|
||||
|
Thanks Nogdog. I'll try it.
And thanks muchly for that other thing too... haven't moved it yet... will get to that later today.
__________________
Oh Lord, please help me be the person my dog thinks I am. |
|
#6
|
||||
|
||||
|
This isn't perfect:
PHP Code:
|
|
#7
|
||||
|
||||
|
wow. I'll need some time to digest all that.
Thanks for the effort. Very much appreciated.
__________________
Oh Lord, please help me be the person my dog thinks I am. |
|
#8
|
|||
|
|||
|
I ran into the same problem as chestertb and with no PECL or CURL installed I was kinda stuck... so I would like to add a BIG thank you to bokeh, his code worked like a charm.
I know it's standard knowledge but I though maybe I should list the possible status returns below, for the full text see: http://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html Status Code Definitions Informational 1xx 100 ContinueSuccessful 2xx 200 OKRedirection 3xx 300 Multiple ChoicesClient Error 4xx 400 Bad RequestServer Error 5xx 500 Internal Server Errorhope this helps you other novices out there.
|
|
#9
|
|||
|
|||
|
Great information thank you
Is there away to do a "POST" and end up on the response page of the other script. for example after you register on one of my sites it takes you to site.com/welcome.htm is it possible to do a http_post from a php script on another site that will still take you to the welcome page on the other site? regards AC |
![]() |
| Bookmarks |
| Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
| Thread Tools | |
| Display Modes | Rate This Thread |
|
|