Re: Forcing a Post of data
| From: | Michael A. Peters | Date: | Tue, 05 May 2009 13:29:59 +0000 |
| Subject: | Re: Forcing a Post of data | ||
| References: | 1 2 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-292264@lists.php.net to get a copy of this message | ||
Ashley Sheridan wrote:
On Tue, 2009-05-05 at 00:09 -0700, Richard Kurth wrote:You can also do it via curl from the server, though I don't know that is what the OP is looking for since he's trying to do it from a link as opposed to just sending post data to a url that just eats it. This is a private function from one of my classes that needs to do it - should show how it is done for those curious. It sends an xml report as post to a uri that eats the post. I think there is another way that involves raw http requests but it looked rather ugly to try and do correctly to me (IE I couldn't figure it out :p) private function httpPostReport() { $rui = $this->csp['report-uri']; $report = $this->triggerDOM->saveXML(); $handle = curl_init(); curl_setopt($handle, CURLOPT_URL,$rui); curl_setopt($handle, CURLOPT_POST, 1); curl_setopt($handle, CURLOPT_POSTFIELDS,$report); curl_setopt($handle, CURLOPT_HTTP_VERSION, CURL_HTTP_VERSION_1_1); curl_setopt($handle, CURLOPT_CONNECTTIMEOUT, 5); $result = curl_exec ($handle); curl_close ($handle); }How can I force this to be a POST and not a GET <a href=customer.php?cid=1&location=customeradd.php> Add Customer </a> or is the only way you can pass data with a POST is from a Form submission.The only way you can send post data is either through the form or using an AJAX call.