Jump to content

Using HTTP_POST to auto fill and submit a form.(AutoLogin)


tommytx

Recommended Posts

Can someone help me with this.. I cannot figure out why it will not log in..  The actual url and user/pass are valid so feel free to test the live site.

 

 

<?php 
// INIT CURL 
$ch = curl_init(); 

// SET URL FOR THE POST FORM LOGIN 
curl_setopt($ch, CURLOPT_URL, 'http://www.handy-hanky.com/shirley/homesell_cron.htm'); 

// ENABLE HTTP POST 
curl_setopt ($ch, CURLOPT_POST, 1); 

// SET POST PARAMETERS : FORM VALUES FOR EACH FIELD 
curl_setopt ($ch, CURLOPT_POSTFIELDS, 'user=tom&pass=test&login_theme=cpanel'); 


curl_setopt ($ch, CURLOPT_RETURNTRANSFER, 1); 

// EXECUTE 1st REQUEST (FORM LOGIN) 
$store = curl_exec ($ch); 

echo "STORE = $store<br>";


// CLOSE CURL 
curl_close ($ch);  

?>

 

 

 

 

Not the biggest buff on cURL, but you should be posting the form processing page (ie, the form "action"), not the form itself.  Looking on the page, it looks like the url the form is posting to is http://www.handy-hanky.com/shirley/success.php, so you'd want to change the url in your curl_setopt function to that.

that worked to send commands to the cron, but only after log in manually... what I am really trying to do is auto log into Cpanel so that I can set crons remotely... i used to do it with the old myuser:[email protected] but that no longer works so I need a work around to do cpanel autolog in... via unattended PHP... can anyone point me in the right direction for automating login to cpanel.. X mode...

 

I posted a similar topic a few days ago where my cURL script wasn't "pressing submit" for me. It was loading my script with the referer set and everything but getting it to "press submit" automatically proved to be a complete pain.

 

If your submit button has the name "sublogin" then you can try this:

curl_setopt ($ch,CURLOPT_POSTFIELDS,'user=tom&pass=test&login_theme=cpanel&sublogin=Commit');

 

If that still fails to work check the form itself in the browser and see if there are any hidden fields set.

that worked to send commands to the cron, but only after log in manually... what I am really trying to do is auto log into Cpanel so that I can set crons remotely... i used to do it with the old myuser:[email protected] but that no longer works so I need a work around to do cpanel autolog in... via unattended PHP... can anyone point me in the right direction for automating login to cpanel.. X mode...

 

 

Why bother logging into CPanel to set cron jobs when cron is a program on the server that can be set directly?

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.