Autologin on a asp based website
Posted: Tue Aug 16, 2011 8:16 am
Hi
I'm trying to do a autologin to our companys supplyer.
I know that the form is on order.se/top.asp
On google i found the following script that i moddiefied for my need, but i still don't get logged in.
I used the Live HTTP Headers to get that post string I should send is the following:
action=login&guid=0&CustomerNo=****&UserPassword=****&UserName=****
Then i return to the top.asp page. beacuse when logged in, the content looks diffrent.
I'm trying to do a autologin to our companys supplyer.
I know that the form is on order.se/top.asp
On google i found the following script that i moddiefied for my need, but i still don't get logged in.
I used the Live HTTP Headers to get that post string I should send is the following:
action=login&guid=0&CustomerNo=****&UserPassword=****&UserName=****
Then i return to the top.asp page. beacuse when logged in, the content looks diffrent.
Code: Select all
<?php
// David Steele
// inventory_updater.php -- Goes out to each of the three websites, logs in, and gets the information
// Note: Some of the code in this program is borrowed from bpat1434 on the page http://www.phpbuilder.com/board/showthread.php?t=10346748 -- Thanks bpat
$cookiePath = "cookies.txt";
function login($loginURL, $username, $userFieldName, $password, $passFieldName, $extraContent, $custno, $custnoFieldName) {
// Initialize the page
$page = curl_init($loginURL);
// Set POST data
curl_setopt($page, CURLOPT_POST, 1);
$postData = $extraContent . $custnoFieldName . '=' . $custno . '&' . $passFieldName . '=' . $password . '&' . $userFieldName . '=' . $username;
// $postData = $userFieldName . '=' . $username . '&' . $passFieldName . '=' . $password;
// if(!empty($extraContent)) $postData = $postData . '&' . $extraContent;
curl_setopt($page, CURLOPT_POSTFIELDS, $postData);
// Set cURL not to print page
curl_setopt($page, CURLOPT_RETURNTRANSFER, true);
// Set the location to store the cookies
curl_setopt($page, CURLOPT_COOKIEJAR, $cookiePath);
curl_setopt($page, CURLOPT_COOKIEFILE, $cookiePath);
// return the cURL variable for later use
return $page;
}
$url = 'http://www.order.se/top.asp';
$username = '****';
$password = '****';
$custno = '****';
$userFieldName = 'UserName';
$passFieldName = 'UserPassword';
$custnoFieldName = 'CustomerNo';
$extraContent = '/logindo.asp action=login&guid=0&';
// $page = login($url);
$page = login($url, $username, $userFieldName , $password, $passFieldName,$extraContent, $custno, $custnoFieldName);
// Go to the page and log in
curl_exec($page);
// Change the URL to the main page to check to see if the user is logged in
// curl_setopt($page, CURLOPT_URL, "http://www.order.se/pricelist.asp");
curl_setopt($page, CURLOPT_URL, "http://www.order.se/top.asp");
// Print the output
print curl_exec($page);
?>