Login to Opencart's admin with curl of PHP Login to Opencart's admin with curl of PHP curl curl

Login to Opencart's admin with curl of PHP


I looked at http://demo.opencart.com/admin/ and saw that the action url in the form is not only /admin. Try this one:

<?phpinclude_once "simple_html_dom.php";$username = 'active';$password = '123active';//$loginUrl = 'http://localhost:100/mywebsite/admin/';//new url$loginUrl = 'http://localhost:100/mywebsite/admin/index.php?route=common/login';$ch = curl_init();curl_setopt($ch, CURLOPT_URL, $loginUrl);curl_setopt($ch, CURLOPT_POST, true );// follows a location header redirectcurl_setopt( $ch, CURLOPT_FOLLOWLOCATION, true );curl_setopt($ch, CURLOPT_POSTFIELDS, 'username='.$username.'&password='.$password);curl_setopt($ch, CURLOPT_COOKIEJAR, 'cookie.txt');curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);$store = curl_exec($ch);$html=new simple_html_dom();$html->load($store);foreach($html->find("li#dashboard") as $dash){    echo $dash->innertext;}?>

I didnt't test if the action url depends on a specific version, so just inspect the form with your browser developer tools