Hi I have a php srcript that receives GET data and I want to redirect the data from GET to another page in wordpress using POST. It's that possible, and how?
Thank's for the help.
Hi I have a php srcript that receives GET data and I want to redirect the data from GET to another page in wordpress using POST. It's that possible, and how?
Thank's for the help.
Only using form and javascript, which is not bulletproof.
The only way this could be done in pure PHP is by using cURL and printing the result of that request in the page:
<?php
// sort post data
$postarray = array();
foreach ($_GET as $getvar => $getval){
$postarray[] = $getvar.'='.urlencode($getval);
}
$poststring = implode('&',$postarray);
// fetch url
$curl = curl_init("http://www.yourdomain.com/yourpage.php");
curl_setopt($ch,CURLOPT_POST,count($postarray));
curl_setopt($ch,CURLOPT_POSTFIELDS,$poststring);
$data = curl_exec($curl);
curl_close($curl);
// print data
print $data;
?>
Obviously you'd validate the GET data before you post it. If there's another way you can do this I'd be interested to know as this method is not ideal. Firstly, cURL must be enabled in PHP, and secondly there will be some overhead in requesting another URL.