Tycoon Talk
Become a Big fish!
The number 1 forum for online business!
Post topics, ask questions, share your knowledge.
Tycoon Talk is part of Freelancer.com - find skilled workers online at a fraction of the cost.

PHP Forum


You are currently viewing our PHP Forum as a guest. Please register to participate.
Login



Freelance Jobs

Reply
cURL to login then complete another form
Old 12-31-2011, 07:44 AM cURL to login then complete another form
Super Talker

Posts: 116
Name: Paul
Location: South Africa
Trades: 0
After many hours of playing and help from here and other places I have managed to figure out how to login to a particular website, then submit a form that you have to be logged in to get to using cURL

This is what I have so far, a problem is that I can not give the website username and password as it is a paid for site that my client has entrusted me with. I can tell you that the site is careerjunction.co.za and within the recruiters section.
Now this site works a little different, first off there is no remember me on the login area, and it uses cookies to let me get around.
If I login, it gives me a cookie, if I try login again from another computer, it gives an error and tells me I have to logout first, with a click here to logout of the other session.
If I login and then click logout, a javascript window asks me if I am sure and then logs me out after pressing yes.
Every month they make you change your password, and have a form come up saying old pass, new pass, repeat new pass.

The script below works only if I am logged out, so this logs in then shows the form, problem is I can not do this a second time 2 days later because I have to logout first, and I can not use it if the account is already logged in.
I would like to adjust the script to logout first, then login and show the form.

PHP Code:
//create a file called cookie.txt and place in site root with perms at 777 first.
//logout page is "http://v1.careerjunction.co.za/usr/mltses.asp?"

curl_login("http://v1.careerjunction.co.za/rec/acc/logfrmupd.asp""Username=example&Password=example""""false");
echo 
curl_grab_page("http://v1.careerjunction.co.za/rec/my/job/jobfrm.asp?recno=-1&p=1&HideTemp=1""""false");

function 
curl_login($url,$data,$proxy,$proxydata){
    
$fp fopen("cookie.txt""w");
    
fclose($fp);
    
$login curl_init();
    
curl_setopt($loginCURLOPT_COOKIEJAR"cookie.txt");
    
curl_setopt($loginCURLOPT_COOKIEFILE"cookie.txt");
    
curl_setopt($loginCURLOPT_USERAGENT"Mozilla/4.0 (compatible; MSIE 5.01; Windows NT 5.0)");
    
curl_setopt($loginCURLOPT_TIMEOUT40);
    
curl_setopt($loginCURLOPT_RETURNTRANSFERTRUE);
    if (
$proxystatus == 'true') {
        
curl_setopt($loginCURLOPT_SSL_VERIFYHOSTFALSE);
        
curl_setopt($loginCURLOPT_HTTPPROXYTUNNELTRUE);
        
curl_setopt($loginCURLOPT_PROXY$proxy);
    }
    
curl_setopt($loginCURLOPT_URL$url);
    
curl_setopt($loginCURLOPT_HEADERTRUE);
    
curl_setopt($loginCURLOPT_USERAGENT$SERVER['HTTP_USER_AGENT']);
    
curl_setopt($loginCURLOPT_FOLLOWLOCATIONTRUE);
    
curl_setopt($loginCURLOPT_POSTTRUE);
    
curl_setopt($loginCURLOPT_POSTFIELDS$data);
    
ob_start(); //prevent any output
    
return curl_exec ($login); //execute the curl command
    
ob_end_clean(); //stop preventing output
    
curl_close ($login);
    unset(
$login);
}
function 
curl_grab_page($site,$proxy,$proxystatus){
    
$ch curl_init();
    
curl_setopt($chCURLOPT_RETURNTRANSFERTRUE);
    if (
$proxystatus == 'true') {
        
curl_setopt($loginCURLOPT_SSL_VERIFYHOSTFALSE);
        
curl_setopt($loginCURLOPT_HTTPPROXYTUNNELTRUE);
        
curl_setopt($loginCURLOPT_PROXY$proxy);
    }
    
curl_setopt($chCURLOPT_COOKIEFILE"cookie.txt");
    
curl_setopt($chCURLOPT_URL$site);
    
ob_start(); //prevent any output
    
return curl_exec ($ch); //execute the curl command
    
ob_end_clean(); //stop preventing output
    
curl_close ($ch);

The end result I would like to have is this
My customer needs to have a form on their own website that once completed needs to go onto their website database, this seems simple enough for me to achieve.
Then they need to be able to complete a very similar form on three other websites without logging into each and filling out the form all over again.
So I would like it that once they have their own form completed, they could click a button and that would submit all the data to the relative site, therefore they would have 3 buttons one for each site they want to submit data to.

I am only dealing with the first site at the moment so I have a very long way to go, and this does not even account for if they want to edit an existing form or anything like that. Whew I think I have bitten off a little more than I bargained for.
Maybe a curl / php expert from here would like to PM me and we can work out some form of remuneration to help me complete this project, I have the entire site designed already and this is just part of the backend of the site. Let me know what sort of $$dolars you think it would cost to help please.
__________________
This was my latest holiday in
Please login or register to view this content. Registration is FREE
South Africa.
This was my favorite adventure holiday in
Please login or register to view this content. Registration is FREE
scorpioserve is offline
Reply With Quote
View Public Profile
 
 
Register now for full access!
Old 12-31-2011, 08:23 PM Re: cURL to login then complete another form
Super Spam Talker

Posts: 879
Name: Paul W
Trades: 0
Have a look at http://www.cs.sunysb.edu/documentation/curl/ - that mentions all that you need, I think.
__________________

Please login or register to view this content. Registration is FREE
|
Please login or register to view this content. Registration is FREE


*** New:
Please login or register to view this content. Registration is FREE
PaulW is offline
Reply With Quote
View Public Profile
 
Old 01-01-2012, 03:44 AM Re: cURL to login then complete another form
Super Talker

Posts: 116
Name: Paul
Location: South Africa
Trades: 0
Well that page gives plenty information, it is really geared towards using cURL from the command line and not through php, I have been through the php cURL reference manual many times and still can not figure this out. That is why I have come here to plead for assistance.
__________________
This was my latest holiday in
Please login or register to view this content. Registration is FREE
South Africa.
This was my favorite adventure holiday in
Please login or register to view this content. Registration is FREE
scorpioserve is offline
Reply With Quote
View Public Profile
 
Reply     « Reply to cURL to login then complete another form
 

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off





   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML



Page generated in 0.39141 seconds with 12 queries