473,394 Members | 1,693 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,394 software developers and data experts.

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

Expand|Select|Wrap|Line Numbers
  1. <?php
  2. $username="user"; 
  3. $password="pass"; 
  4. $cookie="cookie.txt"; 
  5. $url = 'http://www.affilate.mikkelsenmedia.dk/partnersystem/mylogins.php';
  6. $postdata = "username=".$username."&password=".$password."&send=Submit"; 
  7.  
  8. $ch = curl_init(); 
  9. curl_setopt ($ch, CURLOPT_URL, $url); 
  10. curl_setopt ($ch, CURLOPT_SSL_VERIFYPEER, FALSE); 
  11. 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"); 
  12. curl_setopt ($ch, CURLOPT_TIMEOUT, 60); 
  13. curl_setopt ($ch, CURLOPT_FOLLOWLOCATION, 1); 
  14. curl_setopt ($ch, CURLOPT_RETURNTRANSFER, 1); 
  15. curl_setopt ($ch, CURLOPT_COOKIEJAR, $cookie); 
  16. //curl_setopt ($ch, CURLOPT_REFERER, 'http://www.euroads.dk'); 
  17. curl_setopt ($ch, CURLOPT_POSTFIELDS, $postdata); 
  18. curl_setopt ($ch, CURLOPT_POST, 1); 
  19. $result = curl_exec ($ch); 
  20. curl_close($ch);
  21.  
  22. echo $result;
  23. ?>
  24.  
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
Oct 18 '10 #1
0 1632

Sign in to post your reply or Sign up for a free account.

Similar topics

9
by: Dave Martin | last post by:
I've successfully used CURL to maneuver around and through sites but a new site I've been trying to work with has got me stumped. To retrieve the data I'm trying to get a login is required. If...
7
by: Shannon | last post by:
Hi everyone, I am trying to post some data to a form using the XMLHTTP object, and have run into a problem trying to find the proper location of the receiving page. The form points to a...
1
by: Shannon | last post by:
Hi, all -- this is a weird question that does not really have to do with javascript, but I used to spend a lot of time here, and am hoping someone might be able to help... I am trying to...
7
by: Rizaan Jappie | last post by:
is it possible to get the relative path based on a absolute path in c#? *** Sent via Developersdex http://www.developersdex.com *** Don't just participate in USENET...get rewarded for it!
8
by: dw | last post by:
Hello, all. I have a site that I'm testing on my LOCALHOST and also on a remote server, depending on whether I'm at work or at home. I don't want the OLEDBDATAAdapter to be pointing to the remote...
6
by: openleren | last post by:
Hi all, how can I use a relative path in my web.config file for an Access db?: Instead of using <configuration> <appSettings> <add key="conAccess" value="microsoft.jet.oledb.4.0;data...
4
by: Win, Pats | last post by:
I have a snippet of HTML that I inject into a number of pages throughout my Web site at runtime. My problem is that I'm not getting the image to appear in all documents into which this snippet is...
4
by: Paul M. | last post by:
Hi, we have 2 www systems one which we wrote ourselves the other is a parent company one over which we have no control. The 2nd system involves the user having to enter a username & password in a...
2
by: D Godwin | last post by:
This is probably more of a straight HTML question, but here goes: I want to change from http to https during a form submit. This it pretty straightforward with a complete path...
2
by: Ruymán | last post by:
Hello!, is possible use relative path in access? for example use "photo\image1.jpg" instead of "c:\db\photo\image1.jpg", I try it but I cann't, but in Visual Basic if is possible. Other...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.