|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
#1
|
|||
|
|||
|
Matt's Authorization script
Hi,
I'm trying to use Matt's Authorization script (http://codewalkers.com/seecode.php?id=74), but I have no idea how to drop it into real files. I would like to have a setup just like on codewalkers.com. user/pass with login button. Once the user enters the user/pass and it is correct, they can 'do extra stuff' on the site or logout. I will also use the usersOnline script once the authorization is working :-) Any help would be amazing. Matt - a cut & paste would be perfect - it would teach the new guys (like me) how to do stuff properly. thanks. |
|
#2
|
|||||
|
|||||
|
RE: Matt's Authorization script
OK, let me give you a couple of examples...first off to check if someone is logged in or not, do this
php Code:
As an example, I use that exact same thing for the sidebar to see if I should display a login box, or the box that has the preferences, profiles and change password links. In order to get a user name, like how I have it at the top of myCodewalker box when you are logged in...do this Here's the code I use to display to log in form: and here is what I use to actually log a user in (contained in the script the form calls) And the code for the new user stuff in the script that form calls I have another form that the user fills in, and then it gets submitted and sent to $auth->createUser($uname,$pword,$email).. Well, I hope that gets you started a bit, if you run into snags along the way, let me know! |
|
#3
|
|||
|
|||
|
RE: Matt's Authorization script
Matt - superb. Thanks a million. Not sure where you are, but it is 12:34AM where I am, and I appreciate the help.
|
|
#4
|
|||
|
|||
|
RE: Matt's Authorization script
It's the same time here, and I'll be up for quite some time. You may have seen the threads about my new son. I'm pulling night duty to let my wife get rest
|
|
#5
|
|||
|
|||
|
RE: Matt's Authorization script
Matt - I started to assemble the script, using your code as guide.
The function make_seed() is missing from the authorization code. Searched the PHP docs - not there either. Any ideas ? |
|
#6
|
|||
|
|||
|
RE: Matt's Authorization script
Yep...
function make_seed() { list($usec, $sec) = explode(' ', microtime()); return (float) $sec + ((float) $usec * 100000); } Sorry about that! |
|
#7
|
|||
|
|||
|
RE: Matt's Authorization script
Matt,
How does your cw_user.php script look like ? I would guess it validates the user, sets some global variables and goes back to the referrer page ? Those global variables hold user/pass and allow you to stay logged in until you press the logout button - right ? I guess I'm still too new to this to fully get it just yet. A peek at your cw_user.php would solve the mystery - I think ? |
|
#8
|
|||
|
|||
|
RE: Matt's Authorization script
That is the code in the cw_user.php that handles the user login. I would post the whole thing for you, but it would just serve to confuse as I do alot of other sorta unrelated stuff in there. Also, I don't use that exact authorization scheme anymore since I have it integrated with this forum... |
|
#9
|
|||
|
|||
|
RE: Matt's Authorization script
Ok - I know I'm being a pain, but here is what I got so far and I'm getting a weird error:
"Error: A problem was encountered while executing this query." Seems to point to the do_user.php script I think. I'm using your authentication script exactly - called it core_auth.php index.php ------------------ <?php include ("core_auth.php"); php?> <html> <body> <?php $auth = new authenticate; $logged = $auth->checkLogin(); if($logged) { echo "<b>LOGGED IN</b> as "; $username = $auth->getName(); echo $username; } else { echo "<b>NOT LOGGED IN</b>"; echo "<FORM ACTION="do_user.php" METHOD="POST" name="loginform">n"; echo "Username:<BR>n"; echo "<input type="text" size=15 name="uname"><BR>n"; echo "Password:<BR>n"; echo "<input type="password" size=15 name="pword"><BR><BR>n"; echo "<input type="submit" class="button" name="login" value="Login"> n"; echo "</FORM>n"; } php?> </body> </html> -------------------------------- do_user.php -------------------------------- <?php include ("core_auth.php"); $auth = new authenticate; if ($HTTP_POST_VARS['pword'] && $HTTP_POST_VARS['uname']) { if($auth->login($uname,$pword)) { header("Location: $HTTP_REFERER"); } else { echo "Problem logging you in. Try again.n"; } exit; } php?> ---------------------------- Can you help ? |
|
#10
|
|||
|
|||
|
RE: Matt's Authorization script
AHA - found my own BUG !!! Excellent. Off to the races.
Freddy |
|
#11
|
|||
|
|||
|
RE: Matt's Authorization script
where's the error?
the script i tryed it doesn't work! sigh! |
|
#12
|
|||
|
|||
|
RE: Matt's Authorization script
Alex,
What kind of error are you getting? |
|
#13
|
|||
|
|||
|
RE: Matt's Authorization script
Matt,
I am getting the error "Problem logging you in. Try again." I know the username and password is correct because it has been validated and created in the users table. As for my code, it is the exact same as listed in freddy's last post where he listed his code. At the time it looked like he was having problems too, but he never posted his fix. Do you know what could be wrong? I am kinda new to the use of classes, so I am a bit confused. Thanks. |