TalkPHP

TalkPHP (http://www.talkphp.com/forums.php)
-   Script Giveaway (http://www.talkphp.com/script-giveaway/)
-   -   PHP Login Class (http://www.talkphp.com/script-giveaway/1364-php-login-class.html)

daz 10-31-2007 12:07 PM

PHP Login Class
 
1 Attachment(s)
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

maZtah 10-31-2007 05:32 PM

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?

daz 10-31-2007 06:16 PM

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

hostfreak 10-31-2007 08:23 PM

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.

Wildhoney 11-12-2007 05:33 PM

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!

daz 11-13-2007 02:13 AM

Post updated! :)

Wildhoney 11-13-2007 02:28 AM

Good man, Daz :) 2MB limit for ZIP files though. Lots and lots of space!

Haris 11-13-2007 07:02 AM

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!

Wildhoney 11-15-2007 01:59 PM

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!

Haris 11-17-2007 01:32 PM

Quote:

Originally Posted by Wildhoney (Post 4187)
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

zaxis 12-05-2007 05:55 PM

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

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

Wildhoney 12-05-2007 10:39 PM

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.

deflated 12-29-2007 05:43 AM

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

Thanks in advance.

leeburstroghm 03-18-2009 04:40 PM

Hey all, I see there are alot of good things said about Daz login script. I am about to write/find one myself. Does this one have a session/cookie to remember the user, so they dont have to log in each time.? the initial post, has a vers 2 which is not avaialable right now. Is ver2 the one I want or will ver 1 be good. ? is ver 1 without the sql. ? any input? another script perhaps?

CoryMathews 03-22-2009 04:29 PM

daz your link is broke.

amitdgr 03-24-2009 06:00 PM

Daz ,

The link is broken :(


Can you please upload it again ?? This will help a lot of newbies like me ....

Thanks,
Amit

Tanax 03-24-2009 10:27 PM

Have you guys checked the date of this thread? It's more than 1 year old, surely he must have removed the file by now.

captainmerton 05-02-2009 07:29 AM

Help for a Beginner.
 
Hi,

1st post on the site. I'm a PHP beginner well i've written a number of websites but never used OO before so was starting out and thought this login class looked pretty good. In any case I'm running PHP5, Apache2 and mySQL on Windows (my laptop) and when i try and run this seems the exception is caught and thrown out and all I ever get from the index page is:

getMessage(); } /* Include the HTML for the form */ require_once('./lib/form.php'); ?>

...as the error message. I'm hopelessly new to classes however i fully understand what the class is doing but how to debug it well i;m lost on that. I've done all the mysql set uyp work required. I know this is an old thread but any guidance even general would be much appreciated. :-/

sketchMedia 05-02-2009 01:39 PM

try changing the start php tag from:
PHP Code:

<?

to
PHP Code:

<?php

It seems the author used php short tags (which is bad practice, in my opinion for a number of reasons) and you dont have it it enabled.

captainmerton 05-02-2009 03:20 PM

sketchMedia u are a saviour. The fact that it just completely wouldnt work when it had worked for so many others made me think i was going to have to change a setting in my php.ini file or apache config but never crossed my mind about that one. Its now working. Thanks for your help.


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

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