Avatar of rlb1
rlb1

asked on 

RELATED QUESTION: How do I login to this form with cURL (PHP)?

Experts,

I am attempting to login to this form with cURL.  I have attempted several different ways with no luck.
What do you reccomend?  

Is there a way to login without using the form fields like:

$ch = curl_init();
curl_setopt($ch, CURLOPT_RETURNTRANSFER,1);
curl_setopt($ch, CURLOPT_COOKIEFILE, "/cookie.txt");
curl_setopt($ch, CURLOPT_URL,"$caturl");
curl_setopt($ch, CURLOPT_USERPWD, "username:password");


$buf1 = curl_exec ($ch);

curl_close ($ch);


I have also attempted:

$ch = curl_init();
curl_setopt($ch, CURLOPT_COOKIEJAR, "/cookie.txt");
curl_setopt($ch, CURLOPT_URL,"https://www.website.com/login/login.aspx?");
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, " login fields here");

ob_start();      // prevent any output
curl_exec ($ch); // execute the curl command
ob_end_clean();  // stop preventing output

curl_close ($ch);
unset($ch);








Form Code


<form name="aspnetForm" method="post" action="login.aspx" onsubmit="javascript:return WebForm_OnSubmit();" id="aspnetForm">
<div>
<input type="hidden" name="__EVENTTARGET" id="__EVENTTARGET" value="" />
<input type="hidden" name="__EVENTARGUMENT" id="__EVENTARGUMENT" value="" />
<input type="hidden" name="__VIEWSTATE" id="__VIEWSTATE" value="/wEPDwUJNjIzMjk4OTA0D2QWAmYPZBYEAgEPZBYMAgYPFgIeBFRleHQFXgo8bGluayByZWw9InN0eWxlc2hlZXQiIHR5cGU9InRleHQvY3NzIiBocmVmPSIvY3NzL3Y0L3N0eWxlcy5jc3M/MjAxMTA3MDcxMDA0IiBtZWRpYT0iYWxsIiAvPgpkAgcPFgIfAAV7PCEtLVtpZiBJRV0+PGxpbmsgcmVsPSJzdHlsZXNoZWV0IiB0eXBlPSJ0ZXh0L2NzcyIgaHJlZj0iL2Nzcy92NC9zdHlsZXMtaWUuY3NzPzIwMTAxMjA5MDg1MCIgbWVkaWE9InNjcmVlbiIgLz48IVtlbmRpZl0tLT4KZAIIDxYC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UJ1eXMgUGFnZSBJbml0aWFsaXphdGlvbiAtLT4NCmRkaixuZ2OKvSpPLFY95PvqhX3agSg=" />
</div>
 
<script type="text/javascript"> 
//<![CDATA[
var theForm = document.forms['aspnetForm'];
if (!theForm) {
    theForm = document.aspnetForm;
}
function __doPostBack(eventTarget, eventArgument) {
    if (!theForm.onsubmit || (theForm.onsubmit() != false)) {
        theForm.__EVENTTARGET.value = eventTarget;
        theForm.__EVENTARGUMENT.value = eventArgument;
        theForm.submit();
    }
}
//]]>
</script>


<script type="text/javascript"> 
//<![CDATA[
function WebForm_OnSubmit() {
if (typeof(ValidatorOnSubmit) == "function" && ValidatorOnSubmit() == false) return false;
return true;
}
//]]>
</script>


// USERNAME
<input name="ctl00$ct1$txtLogin" type="text" id="ctl00_ct1_txtLogin" />


// PASSWORD&#9;&#9;&#9;&#9;&#9;
<input name="ctl00$ct1$txtPassword" type="password" id="ctl00_ct1_txtPassword" />
&#9;&#9;&#9;&#9;&#9;
&#9;&#9;&#9;&#9;&#9;
// PASSWORD (Not concerned with this)&#9;&#9;&#9;&#9;&#9;
<select name="redirectLst" id="redirectLst" style="width: 132px;">
<option value="basket.aspx">Previous Page</option>
<option value="~/">Home Page</option>
<option value="account.aspx">Your Account</option>
</select>


<input type="submit" name="ctl00$ct1$imgLogin" value="Log In" id="ctl00_ct1_imgLogin" class="submit" />



<script type="text/javascript"> 
//<![CDATA[
var Page_Validators =  new Array(document.getElementById("ctl00_ct1_valUsername"));
//]]>
</script>
 
<script type="text/javascript"> 
//<![CDATA[
var ctl00_ct1_valUsername = document.all ? document.all["ctl00_ct1_valUsername"] : document.getElementById("ctl00_ct1_valUsername");
ctl00_ct1_valUsername.controltovalidate = "ctl00_ct1_txtLogin";
ctl00_ct1_valUsername.errormessage = "Please enter a Username<br/>";
ctl00_ct1_valUsername.display = "Dynamic";
ctl00_ct1_valUsername.validationGroup = "login";
ctl00_ct1_valUsername.evaluationfunction = "RequiredFieldValidatorEvaluateIsValid";
ctl00_ct1_valUsername.initialvalue = "";
//]]>
</script>
 

 
 
<script type="text/javascript"> 
//<![CDATA[
 
var Page_ValidationActive = false;
if (typeof(ValidatorOnLoad) == "function") {
    ValidatorOnLoad();
}
 
function ValidatorOnSubmit() {
    if (Page_ValidationActive) {
        return ValidatorCommonOnSubmit();
    }
    else {
        return true;
    }
}
        //]]>
</script>
</form>

Open in new window

PHPWeb Development

Avatar of undefined
Last Comment
nanharbison
Avatar of nanharbison
nanharbison
Flag of United States of America image

What web host are you using, or are you hosting it in-house?
Avatar of rlb1
rlb1

ASKER

I have a dedicated server at SoftLayer, Formerly The Planet.
Wish I was still with RackSpace.  RackSpace has awesome customer service.  SoftLayer is marginal at best on a good day.
Avatar of nanharbison
nanharbison
Flag of United States of America image

Why are you using cURL for a log in page? Do you have to verify the log in details on a remote server somewhere? Can you just use https instead if the log in has to be secure?
Avatar of rlb1
rlb1

ASKER

nanharbison,

Thanks for your help!!  I am using curl because that is what I have always used and normally it works.  The site is HTTPS.  
If there is a better option, or you have any ideas, I am ready to learn.

Thanks!



Avatar of nanharbison
nanharbison
Flag of United States of America image

Did you check with Softlayer to see if they have some special cURL configuration requirements? I have used cURL on Godaddy and they do, so it might be you are not giving the correct values for some of the variables.
Avatar of rlb1
rlb1

ASKER

nan,
Let me check.  Thanks for your help!  Much appreciated!
ASKER CERTIFIED SOLUTION
Avatar of nanharbison
nanharbison
Flag of United States of America image

Blurred text
THIS SOLUTION IS ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
Avatar of nanharbison
nanharbison
Flag of United States of America image

I asked the biggest developer guru I know, you don't have to use cURL at all for log ins. It doesn't make the log in more secure.
PHP
PHP

PHP is a widely-used server-side scripting language especially suited for web development, powering tens of millions of sites from Facebook to personal WordPress blogs. PHP is often paired with the MySQL relational database, but includes support for most other mainstream databases. By utilizing different Server APIs, PHP can work on many different web servers as a server-side scripting language.

125K
Questions
--
Followers
--
Top Experts
Get a personalized solution from industry experts
Ask the experts
Read over 600 more reviews

TRUSTED BY

IBM logoIntel logoMicrosoft logoUbisoft logoSAP logo
Qualcomm logoCitrix Systems logoWorkday logoErnst & Young logo
High performer badgeUsers love us badge
LinkedIn logoFacebook logoX logoInstagram logoTikTok logoYouTube logo