My program is using a JS XMLHTTP request to a PHP file with cURL code to retrieve the contents of another page. I'm calling a PHP file in order to avoid a cross-origin-request error by the browser. I need to send my PHP file a JS variable, psswd
, so it can use it when executing a cURL request.
I'm using the following JavaScript code to get the contents of another page:
var psswd = "test";
var xmlhttp;
if (window.XMLHttpRequest){ xmlhttp = new XMLHttpRequest(); }
else{ xmlhttp = new ActiveXObject("Microsoft.XMLHTTP"); }
xmlhttp.open("POST", "parsefeed.php?psswd=" + psswd, false);
xmlhttp.send();
My cURL PHP script where i need to use this variable is:
$options = array(
CURLOPT_RETURNTRANSFER => true,
CURLOPT_FOLLOWLOCATION => true,
CURLOPT_SSL_VERIFYHOST => false,
CURLOPT_SSL_VERIFYPEER => false,
CURLOPT_URL => $url ,
CURLOPT_SSLCERT => $cert_file ,
CURLOPT_SSLCERTPASSWD => $< * VARIABLE GOES HERE * >,
);
curl_setopt_array($ch , $options);
$output = curl_exec($ch);
echo $output;
I've tried using $_POST['psswd']
and checking if anything is even posted, but it doesn't seem to work. Any ideas how I can verify the variable is being passed?
jQuery
for crossbrowser compatible ajax calls. – TiMESPLiNTER Jul 15 '14 at 13:55?psswd=" + psswd
to within ofsend
-xmlhttp.send("psswd=" + psswd)
; – eithedog Jul 15 '14 at 13:58