all the scripts i've found are similar to the example code below
Code: Select all
<?php
$loginUrl = 'username=' . $_POST['username'] . '&';
$loginUrl .= 'password=' . $_POST['password'] . '&';
$loginUrl .= 'loginBtn=TRUE';
$url = 'login.php';
$curl = curl_init();
//
curl_setopt($curl, CURLOPT_URL, $url);
curl_setopt($curl, CURLOPT_FAILONERROR, 1);
curl_setopt($curl, CURLOPT_FOLLOWLOCATION, 1);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($curl, CURLOPT_POST, true);
//
curl_setopt($curl, CURLOPT_POSTFIELDS, $loginUrl);
$result = curl_exec($curl);
//
if (curl_errno($curl)) {
echo 'Curl error: ' . curl_error($curl);
exit();
}
?>1. How do i 'call' this page. Currently i have a form that goes to 'login.php' which contains the above sample of code but if i try to load the page containing the form; the page keeps on loading. My knowledge of cURL (and it's use) are limited to what i've read in the php manual.
2. A cURL call like this, how does it compare against a normal POST-ing of login information? Assume that no https will be used, is using cURL anymore secure than just using $_POST?