TalkPHP
 
 
Account Login
Latest Articles
» The basic usage of PHPTAL, a XML/XHTML template library for PHP
» Vulnerable methods and the areas they are commonly trusted in.
» Simple way to protect a form from bot
» The Basics On: How Session Stealing Works
» How to keep your forms from double posting data
Advertisement
Associates
Associates
techtuts Darkmindz
CSS Tutorials Tutorialsphere.com - Free Online Tutorials
Boston PHP SurfnLearn
Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old 10-31-2007, 01:07 PM   #1 (permalink)
daz
The Contributor
Upcoming Programmer 
 
Join Date: Sep 2007
Posts: 31
Thanks: 0
daz is on a distinguished road
Default PHP Login Class

I was going to write a tutorial, but it was too hard trying to explain OO concepts so I'm just going to release the script. Should be pretty secure. Also includes functions for validating an e-mail address and grabbing a user's IP address.

Any feedback/comments welcome, thanks.

Edit:
I updated the script to include an install file and made a few other changes. File is too big to upload here so..

http://www.csscoder.net/private/PHP Login Class v2.zip
Attached Files
File Type: zip PHP Login Class v1.zip (4.7 KB, 1066 views)

Last edited by daz : 11-13-2007 at 02:12 AM.
daz is offline  
Reply With Quote
The Following User Says Thank You to daz For This Useful Post:
codefreek (12-29-2007)
Old 10-31-2007, 06:32 PM   #2 (permalink)
The Acquainted
 
Join Date: Oct 2007
Posts: 130
Thanks: 12
maZtah is an unknown quantity at this point
Default

Great! Thanks for sharing. Such an example is great for learning OOP.
I've noticed a few things I've not seen before, like:

PHP Code:
throw new Exception(Login::ERROR_EMPTY_LOGIN); 
What's it exactly doing? And why are you doing things like that?
maZtah is offline  
Reply With Quote
Old 10-31-2007, 07:16 PM   #3 (permalink)
daz
The Contributor
Upcoming Programmer 
 
Join Date: Sep 2007
Posts: 31
Thanks: 0
daz is on a distinguished road
Default

Hi thanks,

Exceptions are just a OO approach to error-handling. w3schools have a good tutorial on them

http://www.w3schools.com/php/php_exception.asp
daz is offline  
Reply With Quote
Old 10-31-2007, 09:23 PM   #4 (permalink)
The Wanderer
 
hostfreak's Avatar
 
Join Date: Oct 2007
Posts: 21
Thanks: 1
hostfreak is on a distinguished road
Default

Haven't had a chance to really look over much of it, but it might be beneficial to include an sql export to setup the table/field(s). I am sure you will get a lot of beginners complaining that it doesn't work, when in fact they just never set the table/field(s) up.
hostfreak is offline  
Reply With Quote
Old 11-12-2007, 05:33 PM   #5 (permalink)
La Vida es Sueño
Advanced Programmer Top Contributor 
 
Wildhoney's Avatar
 
Join Date: Sep 2007
Location: Oldham
Posts: 1,654
Thanks: 73
Wildhoney is on a distinguished road
Default

Yea, a lot of beginners will stumble and fall when it comes to that. When giving script out to the public, if the script interacts with a database then the SQL should be included. If not, your mail inbox will be filling up pretty quickly!
__________________
The man who comes back through the Door in the Wall will never be quite the same as the man who went out.
Send a message via AIM to Wildhoney Send a message via MSN to Wildhoney Send a message via Yahoo to Wildhoney
Wildhoney is online now  
Reply With Quote
Old 11-13-2007, 02:13 AM   #6 (permalink)
daz
The Contributor
Upcoming Programmer 
 
Join Date: Sep 2007
Posts: 31
Thanks: 0
daz is on a distinguished road
Default

Post updated! :)
daz is offline  
Reply With Quote
Old 11-13-2007, 02:28 AM   #7 (permalink)
La Vida es Sueño
Advanced Programmer Top Contributor 
 
Wildhoney's Avatar
 
Join Date: Sep 2007
Location: Oldham
Posts: 1,654
Thanks: 73
Wildhoney is on a distinguished road
Default

Good man, Daz :) 2MB limit for ZIP files though. Lots and lots of space!
__________________
The man who comes back through the Door in the Wall will never be quite the same as the man who went out.
Send a message via AIM to Wildhoney Send a message via MSN to Wildhoney Send a message via Yahoo to Wildhoney
Wildhoney is online now  
Reply With Quote
Old 11-13-2007, 07:02 AM   #8 (permalink)
The Frequenter
Prolific Welcomer Upcoming Programmer 
 
Join Date: Sep 2007
Posts: 356
Thanks: 24
Haris is on a distinguished road
Default

Thanks for the login class Daz! A good how-to tutorial would be great.

I have an idea for you, make a simple webpage (with your css skills) with link to your login class and a full documentation on how-to use and expand the class. :)

Good linkbait. :D

Erm and Adam, I don't seem to get the PHP5 exceptions. Might want to see your inbox!
Haris is offline  
Reply With Quote
Old 11-15-2007, 01:59 PM   #9 (permalink)
La Vida es Sueño
Advanced Programmer Top Contributor 
 
Wildhoney's Avatar
 
Join Date: Sep 2007
Location: Oldham
Posts: 1,654
Thanks: 73
Wildhoney is on a distinguished road
Default

Exceptions article has been written for 2 days :) Just sat in proof read forum along with many other juicy articles. So many requests for Daz, don't want to make him start regretting it!
__________________
The man who comes back through the Door in the Wall will never be quite the same as the man who went out.
Send a message via AIM to Wildhoney Send a message via MSN to Wildhoney Send a message via Yahoo to Wildhoney
Wildhoney is online now  
Reply With Quote
Old 11-17-2007, 01:32 PM   #10 (permalink)
The Frequenter
Prolific Welcomer Upcoming Programmer 
 
Join Date: Sep 2007
Posts: 356
Thanks: 24
Haris is on a distinguished road
Default

Quote:
Originally Posted by Wildhoney View Post
Exceptions article has been written for 2 days :) Just sat in proof read forum along with many other juicy articles. So many requests for Daz, don't want to make him start regretting it!
He will be getting all the popularity and monies! :p
Haris is offline  
Reply With Quote
Old 12-05-2007, 05:55 PM   #11 (permalink)
The Visitor
Newcomer 
 
Join Date: Dec 2007
Location: Florida
Posts: 2
Thanks: 0
zaxis is on a distinguished road
Default Cool

Hey this is a cool script. I'm glad I found it, I was just about to create my own Login class

For the next version I think a class that can handle more than one type of DB would be great. (I'm not sure PHP supports interfaces, but I'm sure there's a way to do it.)

Thanks,

Brian
zaxis is offline  
Reply With Quote
Old 12-05-2007, 10:39 PM   #12 (permalink)
La Vida es Sueño
Advanced Programmer Top Contributor 
 
Wildhoney's Avatar
 
Join Date: Sep 2007
Location: Oldham
Posts: 1,654
Thanks: 73
Wildhoney is on a distinguished road
Default

Yea, PHP can handle interfaces. It would be nice to pass in the type of the database you're wanting to use to the construct, I do admit.
__________________
The man who comes back through the Door in the Wall will never be quite the same as the man who went out.
Send a message via AIM to Wildhoney Send a message via MSN to Wildhoney Send a message via Yahoo to Wildhoney
Wildhoney is online now  
Reply With Quote
Old 12-29-2007, 05:43 AM   #13 (permalink)
The Wanderer
 
deflated's Avatar
 
Join Date: Dec 2007
Location: 127.0.0.1
Posts: 18
Thanks: 7
deflated is on a distinguished road
Default

Unfortunately the server is not reachable. I'm really interested in that class as I've written something similar.

Thanks in advance.
Tim
deflated is offline  
Reply With Quote
The Following User Says Thank You to deflated For This Useful Post:
codefreek (12-29-2007)
Reply



Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

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

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


All times are GMT. The time now is 12:37 PM.

 
     

Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.1.0