Advertisement

05.14.2008 at 11:46AM PDT, ID: 23402663
[x]
Attachment Details
[x]
The Solution Rating System

With so many solutions, how can you tell which solutions are most likely to help you and which ones are not? To provide you with a tool to use, we rate our solutions based on various elements that most accurately determine if a solution is a quality solution. To explain what factors affect the solution rating, here are the elements we take into consideration when formulating our solution rating.

  • The Grade of the Solution
  • The Zone Rank of the Expert Providing the Solution
  • The Number of Author and Expert Comments
  • The Number of Experts Contributing
  • The Feedback of the Community

Your Input Matters
Because of the way the system is set up, the most important variable in this equation is you. As a member of Experts Exchange, you are able to cast your vote on the quality of the solutions in regard to how complete, accurate, helpful and easy to understand each solution is. When you provide your feedback, each rating is adjusted accordingly. So, if you see a solution that has a poor rating that you think is a good solution, let us know by rating it. As you do, the rating will be adjusted and will become more accurate for other members of our site.

If you have any suggestions that you would like to make for our rating system, please ask a question in the Suggestions Zone of Community Support.

Thank you!

8.6

Logging on a site with CURL and redirecting into the site

Asked by Londo1000 in PHP Scripting Language, Miscellaneous Web Development, Active Server Pages (ASP)

Hello all,

Using PHP and CURL I am trying to login into a client's site on their login page.  Once logged in, I need the browser to open up the page that the login page redirects to (https://www.abc-ca.org/main_page.asp).  Manually if I login then I will be properly redirected to https://www.abc-ca.org/main_page.asp.

I need to simulate that process in my php script so that the browser will log in and end up at the redirected page https://www.abc-ca.org/main_page.asp.  Using my attached code I am able to properly authenticate and using the echo(curl_exec($curl)) line, I can see the page but within my current page not a redirected page.  Also since this is running locally and only retrieving the resulting html, none of the graphics from the destination page show  This is not exactly what I want.  I want to be able to be authenticated and properly redirected to https://www.abc-ca.org/main_page.asp.

I tried to use the header ( 'Location: '.$url) syntax to redirect to https://www.abc-ca.org/main_page.asp but that didn't work since it seems to be passing a get instead of a post.  I thought that the folllowlocation option would do it for me but that wasn't the case.

FYI.  The spec for the login page from the client is as follows:

<form id="frmSender" action="https://www.abc-ca.org/login.asp" method="post">
<input type="hidden" id="UserID" name="UserID" runat="server" value="" />
<input type="hidden" id="Password" name="Password" runat="server" value="" />
<input type="button" value="send it" onclick="javascript:submit();" />
</form>
 

Can somebody tell me what code I need to add after my authentication so that I can be properly redirected to  https://www.abc-ca.org/main_page.asp?

Thanks..Start Free Trial
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
<?php
 
  $url = "https://www.abc-ca.org/LOGIN.ASP";
  $curl = curl_init();
  $curlPost = 'UserID=12345&Password=654321&Login=Login&return=&return=';
  curl_setopt($curl, CURLOPT_USERAGENT, "$_SERVER[HTTP_USER_AGENT]");
  curl_setopt($curl, CURLOPT_HEADER, 0);
  curl_setopt($curl, CURLOPT_FOLLOWLOCATION, 1);
  curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, 0);  // this line makes it work under https
  curl_setopt($curl, CURLOPT_SSL_VERIFYHOST,  1);
  curl_setopt($curl, CURLOPT_URL, $url);
  curl_setopt($curl, CURLOPT_CRLF, 1);
  curl_setopt($curl, CURLOPT_COOKIEFILE, "cookie.txt");
  curl_setopt($curl, CURLOPT_COOKIEJAR, "cookie.txt");
  curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
  curl_setopt($curl, CURLOPT_POST, 1);
  curl_setopt($curl, CURLOPT_POSTFIELDS, $curlPost);
  echo(curl_exec($curl));
  curl_close($curl);
?>
[+][-]05.16.2008 at 03:05PM PDT, ID: 21586803

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]05.18.2008 at 12:36PM PDT, ID: 21593743

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]05.20.2008 at 10:23AM PDT, ID: 21608273

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]05.21.2008 at 01:39AM PDT, ID: 21613038

View this solution now by starting your 7-day free trial. Setting up your free trial is quick, easy, and secure. We will return you to this solution, unlocked, when you're done.

 

About this solution

Zones: PHP Scripting Language, Miscellaneous Web Development, Active Server Pages (ASP)
Sign Up Now!
Solution Provided By: Squinky
Participating Experts: 2
Solution Grade: B
 
 
 
Loading Advertisement...
20080716-EE-VQP-32 / EE_QW_2_20070628