The Cache: Technology Expert's Forum
 
*
Welcome, Guest. Please login or register. September 19, 2019, 02:28:04 PM

Login with username, password and session length


Pages: [1]
  Print  
Author Topic: login script troubleshoot  (Read 4997 times)
jbone
Rookie
**
Offline Offline

Posts: 10


View Profile
« on: February 13, 2009, 03:02:23 PM »

Ok so this is what i got and im getting incorrect T_VARIABLE for $pass? Any suggestions.

<?php
error_reporting (e_all);
$login = user
$pass = pass
$ch = curl_init();
$pvar['log']= $login;
$pvar['password'] = $pass;
$pvar['ok'] = 'login';

curl_setopt($ch, CURLOPT_URL, 'http://members.domain.com');
curl_setopt($ch, curlopt_header, 0);
curl_exec($ch);


curl_close($ch);

?>

 Need Help
Logged

No links in signatures please
jbone
Rookie
**
Offline Offline

Posts: 10


View Profile
« Reply #1 on: February 13, 2009, 03:43:45 PM »

Ahh well i fixed  a few issues but still no luck

like this
curl_setopt($ch,CURLOPT_POSTFIELDS,$pvar);
was missing and
$user = 'user';
$password = "password':
;;;; these were missing.
Its a login popup like hostgators
Logged

No links in signatures please
nutballs
Administrator
Lifer
*****
Offline Offline

Posts: 5627


Back in my day we had 9 planets


View Profile
« Reply #2 on: February 13, 2009, 04:12:23 PM »

err. are you ever telling curl what url to hit? with your new code that is?
Logged

I could eat a bowl of Alphabet Soup and shit a better argument than that.
jbone
Rookie
**
Offline Offline

Posts: 10


View Profile
« Reply #3 on: February 13, 2009, 04:15:32 PM »

Heres what i have im still missing something.

<?php
error_reporting (e_all);
$username = user;
$pass =password;

$ch = curl_init();
  $pvar['log']= $username;
  $pvar['password'] = $pass;
  $pvar ['testcookie'] = '1';
  $pvar ['redirect_to'] = 'http://members.domain.com/';
  $pvar ['submit'] = 'ok';

curl_setopt($ch, CURLOPT_URL, 'http://members.domain.com');
curl_setopt($ch, CURLOPT_HEADER, 0);
curl_setopt($ch,CURLOPT_POSTFIELDS,$pvar);


curl_exec($ch);


curl_close($ch);

?>
Logged

No links in signatures please
jbone
Rookie
**
Offline Offline

Posts: 10


View Profile
« Reply #4 on: February 13, 2009, 04:21:43 PM »

would I need a curlopt_followlocation?
Logged

No links in signatures please
nutballs
Administrator
Lifer
*****
Offline Offline

Posts: 5627


Back in my day we had 9 planets


View Profile
« Reply #5 on: February 13, 2009, 04:23:44 PM »

not being curl user I have no idea on the options and such. just looking at it from a php point of view.

this chunk:
$username = user;
$pass =password;

if those are hard coded, they need to be wrapped with quotes
$username = 'user';
$pass = 'password';

someone else might be able to help with the curl stuff though.
Logged

I could eat a bowl of Alphabet Soup and shit a better argument than that.
jbone
Rookie
**
Offline Offline

Posts: 10


View Profile
« Reply #6 on: February 13, 2009, 04:27:42 PM »

not being curl user I have no idea on the options and such. just looking at it from a php point of view.

this chunk:
$username = user;
$pass =password;

if those are hard coded, they need to be wrapped with quotes
$username = 'user';
$pass = 'password';

someone else might be able to help with the curl stuff though.
Yes i do have it wrapped thank you , i really appreciate the help
Logged

No links in signatures please
jbone
Rookie
**
Offline Offline

Posts: 10


View Profile
« Reply #7 on: February 13, 2009, 04:30:30 PM »

not being curl user I have no idea on the options and such. just looking at it from a php point of view.

Im new to php and curl but i figured that curl would be easier to do and more straight forward.
Logged

No links in signatures please
perkiset
Olde World Hacker
Administrator
Lifer
*****
Offline Offline

Posts: 10096



View Profile
« Reply #8 on: February 13, 2009, 04:38:11 PM »

JB - the thread @ Syndk8 lists your error a little better than your first post here: syntax error, unexpected T_VARIABLE in  line 4

If your code is literally only

<?php
error_reporting (e_all);
$username = 'user';
$pass = 'password';

$ch = curl_init();

and you are getting a syntax error, then may I ask - did you copy and paste this from a website somewhere? There are no syntax errors in those 4 lines of code... so I am wondering if you have a hidden invisible char in there, it's happened to me before.

Backspace over all the white space in the code and see if that does it - or if you have a reasonable text editor you can try to show invisibles or, in BBE or TextEdit case, you select "Text | Zap Gremlins" to get rid of invisible crappiness that can cause this very type of error.

Give'r a try and see if that gives you any different symptoms.
Logged

It is now believed, that after having lived in one compound with 3 wives and never leaving the house for 5 years, Bin Laden called the U.S. Navy Seals himself.
jbone
Rookie
**
Offline Offline

Posts: 10


View Profile
« Reply #9 on: February 13, 2009, 04:52:14 PM »

JB - the thread @ Syndk8 lists your error a little better than your first post here: syntax error, unexpected T_VARIABLE in  line 4

If your code is literally only

<?php
error_reporting (e_all);
$username = 'user';
$pass = 'password';

$ch = curl_init();

and you are getting a syntax error, then may I ask - did you copy and paste this from a website somewhere? There are no syntax errors in those 4 lines of code... so I am wondering if you have a hidden invisible char in there, it's happened to me before.

Backspace over all the white space in the code and see if that does it - or if you have a reasonable text editor you can try to show invisibles or, in BBE or TextEdit case, you select "Text | Zap Gremlins" to get rid of invisible crappiness that can cause this very type of error.

Give'r a try and see if that gives you any different symptoms.

No i didnt copy and paste and i am still getting a 401 error page with this code
<?php
error_reporting (e_all);
$username = 'user';
$pass ='password';

$ch = curl_init();
  $pvar['log']= $username;
  $pvar['password'] = $pass;
  $pvar ['testcookie'] = '1';
  $pvar ['redirect_to'] = 'http://members.domain.com/';
  $pvar ['submit'] = 'ok';

curl_setopt($ch, CURLOPT_URL, 'http://members.domain.com');
curl_setopt($ch, CURLOPT_HEADER, 0);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS,$pvar);


curl_exec($ch);


curl_close($ch);

?>

But i did copy and paste this below from the syndk8 wordpress login thread and i think it worked... im not getting a 401 but not for sure.
<?

$ch = curl_init();
 error_reporting (e_all);
$username = 'user';
$password = 'pass';

$ch = curl_init();
  $pvar['log']= $username;
  $pvar['password'] = $password;
  $pvar ['testcookie'] = '1';
  $pvar ['redirect_to'] = 'http://members.domain.com/';
  $pvar ['ok'] = 'login';

   
    curl_setopt($ch, CURLOPT_POST,true);
    curl_setopt($ch, CURLOPT_POSTFIELDS, $pvar);
    curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
    curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 2);
    curl_setopt($ch, CURLOPT_FOLLOWLOCATION,true);
    curl_setopt($ch, CURLOPT_URL, "https://members.domain.com");
    curl_setopt($ch, CURLOPT_REFERER, "https://members.domain.com");
    //curl_setopt($ch, CURLOPT_HEADER, 1);
    $output = curl_exec($ch);
    //echo $output;
    echo 'Logged in!
';

Thanks perkiset
Logged

No links in signatures please
perkiset
Olde World Hacker
Administrator
Lifer
*****
Offline Offline

Posts: 10096



View Profile
« Reply #10 on: February 13, 2009, 04:54:58 PM »

Well if you've got the syntax error nailed that's great.

I'm no cURL guy, I use my own class - but I notice that in the script you copied from Syndk8 you're going to an https site, and in your script you're going to an http, which could definitely account for your 401.


Logged

It is now believed, that after having lived in one compound with 3 wives and never leaving the house for 5 years, Bin Laden called the U.S. Navy Seals himself.
jbone
Rookie
**
Offline Offline

Posts: 10


View Profile
« Reply #11 on: February 13, 2009, 05:01:46 PM »

Well if you've got the syntax error nailed that's great.

I'm no cURL guy, I use my own class - but I notice that in the script you copied from Syndk8 you're going to an https site, and in your script you're going to an http, which could definitely account for your 401.




Ya i noticed that too and its supposed to be http: so when i changed it back i got a 401. hmmm ill have to read more Mobster
Logged

No links in signatures please
patch
Rookie
**
Offline Offline

Posts: 32


View Profile
« Reply #12 on: February 15, 2009, 07:48:34 AM »

are you sure you're passing a in ALL the relevant Post variables?

just a thought....
Logged
blackhound
n00b
*
Offline Offline

Posts: 3


View Profile
« Reply #13 on: June 12, 2009, 09:10:09 AM »

are you sure you're passing a in ALL the relevant Post variables?

just a thought....

OP may have already fixed this but you shouldn't get a 401 error generally if you are missing post data you should get the login failed page if you are going are following. At least that is what I get from my relatively limited experience with Curl
Logged

No links in signatures please
vsloathe
vim ftw!
Global Moderator
Lifer
*****
Offline Offline

Posts: 1669



View Profile
« Reply #14 on: June 13, 2009, 07:09:49 PM »

Weird that I never noticed this before.

You hand cURL an array, it's going to do a multipart form post. Don't give it an array give it a string.
Logged

hai
Pages: [1]
  Print  
 
Jump to:  

Perkiset's Place Home   Best of The Cache   phpMyIDE: MySQL Stored Procedures, Functions & Triggers
Politics @ Perkiset's   Pinkhat's Perspective   
cache
mart
coder
programmers
ajax
php
javascript
Powered by MySQL Powered by PHP Powered by SMF 1.1.2 | SMF © 2006-2007, Simple Machines LLC
Seo4Smf v0.2 © Webmaster's Talks


Valid XHTML 1.0! Valid CSS!