دنبال کننده ها

۱۳۹۶ شهریور ۹, پنجشنبه

curl - PHP form to moneris through google recaptcha

[ad_1]



I have a simple PHP form which sends information to the Moneris through Google recaptcha verification.



That means i cannot just write this "https://esqa.moneris.com/HPPDP/index.php">" as i need google recaptcha verification.



Is there any way if i can just submit the form in the PHP code which takes users to this page https://esqa.moneris.com/HPPDP/index.php with all form values.



I am using Curl which is displaying the result from this URL to my website https://esqa.moneris.com/HPPDP/index.php but it is not working really well so i just want users to go to the above URL with all the post information.



My CURL code which is not working properly



$url = 'https://esqa.moneris.com/HPPDP/index.php';
$fields = array(
'ps_store_id'=>urlencode('GDTJ4tore1'),
'hpp_key'=>urlencode('hpAJL6HNUSEC'),
'charge_total'=>urlencode('1.00'),
);
foreach($fields as $key=>$value) $fields_string .= $key.'='.$value.'&';
rtrim($fields_string,'&');
// google recaptcha
$recaptcha_secret = "secret key";
$response = file_get_contents("https://www.google.com/recaptcha/api/siteverify?secret=".$recaptcha_secret."&response=".$_POST['g-recaptcha-response']);
$response = json_decode($response, true);
if($response["success"] === true)

$ch = curl_init();
curl_setopt($ch,CURLOPT_URL,$url);
curl_setopt($ch,CURLOPT_POST,count($fields));
curl_setopt($ch,CURLOPT_POSTFIELDS,$fields_string);
$result = curl_exec($ch);
curl_close($ch);

else

echo "error";




[ad_2]

لینک منبع