I've tried again and again but I can't get it to work. How can I POST data from my PHP script and retrieve the results??
POST in PHP
Started by falco85, Sep 06 2006 04:00 PM
4 replies to this topic
#1
Posted 06 September 2006 - 04:00 PM
|
|
|
#2
Posted 09 September 2006 - 08:31 AM
Hi Falco,
Can you tell me if your trying to POST to another HOST or if your using a FORM and want to display the results of the entered fields?
Can you tell me if your trying to POST to another HOST or if your using a FORM and want to display the results of the entered fields?
#3
Guest_Jordan_*
Posted 09 September 2006 - 09:13 AM
Guest_Jordan_*
Yes, if you are trying to post using a FORM it is a little different than if you are posting to another host. Form post, as you may know, is simply HTML:
Here is how you POST to a form using [ CURL ] on another host:
To get the page only using the URL (no POST data):
<form action="postscript.php" method="POST">
Here is how you POST to a form using [ CURL ] on another host:
<? $url="http://anything"; $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, $url); curl_setopt ($ch, CURLOPT_POST, 1); curl_setopt ($ch, CURLOPT_POSTFIELDS, "fieldname=fieldvalue&fieldname=fieldvalue&"); #curl_setopt ($ch, CURLOPT_COOKIEJAR, 'cookie.txt'); curl_setopt ($ch, CURLOPT_RETURNTRANSFER, 1); $store = curl_exec ($ch); $content = curl_exec ($ch); # This returns HTML curl_close ($ch); ?>
To get the page only using the URL (no POST data):
<? $url="http://anything"; $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, $url); curl_setopt ($ch, CURLOPT_RETURNTRANSFER, 1); $store = curl_exec ($ch); $xml = curl_exec ($ch); curl_close ($ch); ?>
#4
Posted 13 September 2006 - 06:15 AM
Some places do not let you post like Google. You had better check the TOS of the sites you want to post/retrieve from.
#5
Posted 14 September 2006 - 05:24 PM
also depending on your registred global settings you may have to use $_POST['variable'] on the page you are posting to.


Sign In
Create Account


Back to top









