473,396 Members | 2,111 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,396 software developers and data experts.

Login to a forum using php and curl

I want to creat a weblogin client using php to login to this forum or someother.
but i am gating with the page that u have to login befor precede.
I am new to curl so cannot figure out where the problem is.


[PHP]
<?php
$usrname="xxxxxx";
$password="xxxxxxx";
$loginURL="http://www.thescripts.com/forum/login.php?do=showlogin";
$reffer="http://www.thescripts.com/forum/usercp.php?";
$cookiepath="/tmp/cookielog";
$agent = "Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; rv:1.4) Gecko/20030624 Netscape/7.1 (ax)";
$ch = curl_init();
curl_setopt($ch, CURLOPT_COOKIEJAR, $cookiepath);
curl_setopt($ch, CURLOPT_URL,$loginURL);
curl_setopt($ch, CURLOPT_USERAGENT, $agent);
curl_setopt($ch,CURLOPT_POST,1);
curl_setopt($ch,CURLOPT_POSTFIELDS,'vb_login_usern ame='.$usrname.'&vb_login_password='.$password);
ob_start();
curl_exec($ch);
ob_end_clean();
curl_close ($ch);
unset($ch);
$ch = curl_init();
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_COOKIEFILE, $cookiepath);
curl_setopt($ch, CURLOPT_URL,$reffer);
$result = curl_exec ($ch);
print $result;
curl_exec($ch);
curl_close ($ch);
?>

[/PHP]
May 23 '07 #1
8 3260
pbmods
5,821 Expert 4TB
Could you be more specific with what you're trying to accomplish here? Are you creating an auto-login script for your own personal use, or is this something you want to eventually put on a publicly-accessible website?
May 23 '07 #2
Motoma
3,237 Expert 2GB
The biggest problem you have here is that you are not collecting and setting the user COOKIES for the site you are trying to connect to.
May 23 '07 #3
This manily for my Learning Perpose i mentioned early that iam new in curl and php also oviously for my personal use not for any public use.
yes iam collection cookies by curl cookiejar option and store the cookies in /tmp .That is what i understand to use curl with cookies , i donot have any detailed idea.
May 23 '07 #4
Motoma
3,237 Expert 2GB
Take a look at the form variables that are being sent to the login page. There are a few more than the ones you are POSTing.
May 23 '07 #5
i have no idea how to post those hidden fields coz they may have certain value embeded and also they have md5hasing which php have a function of md5 but how to use those .
May 23 '07 #6
Motoma
3,237 Expert 2GB
i have no idea how to post those hidden fields coz they may have certain value embeded and also they have md5hasing which php have a function of md5 but how to use those .
The chore of your project will be figuring these things out, watching (with Wireshark perhaps) what is getting POSTed and emulating that in your application.
MD5 is easy, just call it:

Expand|Select|Wrap|Line Numbers
  1. $pass = "dumb passphrase";
  2. $md5pass = md5($pass);
  3.  
May 23 '07 #7
how to find out what is gating posted
May 25 '07 #8
Motoma
3,237 Expert 2GB
how to find out what is gating posted
Wireshark is my favorite tool, but you could always use Fiddler. Fiddler is a bit more straightforward, and, it is designed with HTTP in mind.
May 25 '07 #9

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

Similar topics

2
by: bryce21 | last post by:
I'm trying to write a script that logs into Yahoo Fantasy Football. Once logged in, I'll be able to grab stats and various other pieces of info about our league. The problem I'm having deals with...
0
by: nfhm2k | last post by:
I've been trying to find a solution to this for quite some time now... I even took a look at existing scripts... Including this one......
6
by: joe t. | last post by:
The subject may sound a little cryptic, so i'll try my best to explain. Details are unavailable, as i am under a nondisclosure agreement, but i'm looking for general principles and tips, not...
2
by: laredotornado | last post by:
Hi, Using Apache web server, I am protecting certain directories with ..htaccess files. Is there a way in PHP where I can automatically sjbmit login credentials without having to type them into...
1
by: GeoffreyF67 | last post by:
There is a social bookmarking site here: http:// onlywire.com that I'm trying to login and post to via curl. It's using ajax and I haven't been able to figure out how to post to it so far. ...
3
by: JDS | last post by:
So, I'd like to create the following scenario: 1) Use cURL library within PHP (cURL + "Cookie Jar", et.al) to create a virtual browser session that "logs in" to a remote site. (For example: ...
2
by: adam.waterfield | last post by:
Maybe someone could help me a little here. On a project I am working on, we have some LDAP authentication to Active Directory which allows users to login to our application - this is fine. When...
4
by: adam.waterfield | last post by:
I am just wondering if anyone here can help with a problem that we have here. We have a PHP based website/application that has a user login that is connected to our AD setup. This works fine....
3
by: buzz2050 | last post by:
Hi all, I am using cURL for the first time. I need to login to a site and my cURL code to do the same is as follows: //curlScript.php <?php function getContent($url, $referer,...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
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
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

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.