bidoun
10-30-2009, 05:28 PM
Hello
I want login with my username and password to my Joomla admin account with cURL. The code seem to be fine but still couldn't login and I ignore the reason, I create a working account for test :
Url to admin authentication page : http://www.fsr.servhome.org/administrator/?admin
Username : demo
Password : demo/
Here the php file script.php :
<?php
$fields['task'] = 'login';
$fields['option'] = 'com_login';
$fields['username'] = 'demo';
$fields['passwd'] = 'demo/';
$urlLogin = 'http://www.fsr.servhome.org/administrator/?admin';
$useragent = 'Mozilla/5.0';
$referer = $urlLogin;
$urlLogout = 'http://www.fsr.servhome.org/administrator/index.php?option=com_login&task=logout';
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $urlLogin);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, $fields);
curl_setopt($ch, CURLOPT_USERAGENT, $useragent);
curl_setopt($ch, CURLOPT_REFERER, $referer);
curl_setopt($ch, CURLOPT_COOKIESESSION, 1);
curl_setopt ($curl, CURLOPT_COOKIEJAR, 'cookie.txt');
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
$result = curl_exec($ch);
curl_setopt($ch, CURLOPT_URL, $urlLogout);
curl_setopt($ch, CURLOPT_COOKIESESSION, 1);
curl_setopt($ch, CURLOPT_COOKIEFILE, 'cookie.txt');
curl_setopt($ch, CURLOPT_USERAGENT, $useragent);
curl_setopt($ch, CURLOPT_REFERER, $urlLogout);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
$result = curl_exec($ch);
curl_close($ch);
?>
Think You
I want login with my username and password to my Joomla admin account with cURL. The code seem to be fine but still couldn't login and I ignore the reason, I create a working account for test :
Url to admin authentication page : http://www.fsr.servhome.org/administrator/?admin
Username : demo
Password : demo/
Here the php file script.php :
<?php
$fields['task'] = 'login';
$fields['option'] = 'com_login';
$fields['username'] = 'demo';
$fields['passwd'] = 'demo/';
$urlLogin = 'http://www.fsr.servhome.org/administrator/?admin';
$useragent = 'Mozilla/5.0';
$referer = $urlLogin;
$urlLogout = 'http://www.fsr.servhome.org/administrator/index.php?option=com_login&task=logout';
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $urlLogin);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, $fields);
curl_setopt($ch, CURLOPT_USERAGENT, $useragent);
curl_setopt($ch, CURLOPT_REFERER, $referer);
curl_setopt($ch, CURLOPT_COOKIESESSION, 1);
curl_setopt ($curl, CURLOPT_COOKIEJAR, 'cookie.txt');
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
$result = curl_exec($ch);
curl_setopt($ch, CURLOPT_URL, $urlLogout);
curl_setopt($ch, CURLOPT_COOKIESESSION, 1);
curl_setopt($ch, CURLOPT_COOKIEFILE, 'cookie.txt');
curl_setopt($ch, CURLOPT_USERAGENT, $useragent);
curl_setopt($ch, CURLOPT_REFERER, $urlLogout);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
$result = curl_exec($ch);
curl_close($ch);
?>
Think You