Automatic Login to websites where form action = 'relative path'

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Lunatiko

    #1

    Automatic Login to websites where form action = 'relative path'

    Code:
    <?php
    $username="user"; 
    $password="pass"; 
    $cookie="cookie.txt"; 
    $url = 'http://www.affilate.mikkelsenmedia.dk/partnersystem/mylogins.php';
    $postdata = "username=".$username."&password=".$password."&send=Submit"; 
    
    $ch = curl_init(); 
    curl_setopt ($ch, CURLOPT_URL, $url); 
    curl_setopt ($ch, CURLOPT_SSL_VERIFYPEER, FALSE); 
    curl_setopt ($ch, CURLOPT_USERAGENT, "Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.1.6) Gecko/20070725 Firefox/2.0.0.6"); 
    curl_setopt ($ch, CURLOPT_TIMEOUT, 60); 
    curl_setopt ($ch, CURLOPT_FOLLOWLOCATION, 1); 
    curl_setopt ($ch, CURLOPT_RETURNTRANSFER, 1); 
    curl_setopt ($ch, CURLOPT_COOKIEJAR, $cookie); 
    //curl_setopt ($ch, CURLOPT_REFERER, 'http://www.euroads.dk'); 
    curl_setopt ($ch, CURLOPT_POSTFIELDS, $postdata); 
    curl_setopt ($ch, CURLOPT_POST, 1); 
    $result = curl_exec ($ch); 
    curl_close($ch);
    
    echo $result;
    ?>
    I tried this code to automatically login to a website where form action is not an absolute path. Each time i try this code in the locally, it redirects me to the index of localhost. Maybe because the form action has a relative path. Question is, how would i be able to change the action from relative to absolute before actually submitting the form and before executing the curl session. Need immediate response. Thanks
Working...