I'm trying to post CURL data to an ASP page .This is the website I'm trying to post data to :
https://www.evat.ir/vatlogin/frmLogi...px%3fp%3d1&p=1
It has two fields which is the username and password and I'm trying to post the username and password by using CURL. How could I do so ?
Thanks
use CURLOPT_USERPWD header for authentication.
$username='your username';
$password='your password';
$URL='your asp url';
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL,$URL);
curl_setopt($ch, CURLOPT_TIMEOUT, 30); //timeout after 30 seconds
curl_setopt($ch, CURLOPT_RETURNTRANSFER,1);
curl_setopt($ch, CURLOPT_HTTPAUTH, CURLAUTH_ANY);
curl_setopt($ch, CURLOPT_USERPWD, "$username:$password");
$status_code = curl_getinfo($ch, CURLINFO_HTTP_CODE); //get status code
$result=curl_exec ($ch);
curl_close ($ch);
Hope it will help
<?php
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL,"http://www.yoursite.com/index.asp"); //url to post the data
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, "variable1=username&variable2=password"); // use $_POST["username"] && $_POST["password"] while posting username and password
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$execute = curl_exec ($ch);
curl_close ($ch);
if ($execute == "OK") { echo " data successfully posted";}
else { echo "not posted";}
?>
Hope this helps!