PHP (OOP) Login System Logic/Structure

Converting my procedural login system, need help with the logic.

Page 1 of 1

4 Replies - 10041 Views - Last Post: 23 August 2010 - 04:30 AM Rate Topic: -----

#1 PhunkRabbit  Icon User is offline

  • D.I.C Regular
  • member icon

Reputation: 81
  • View blog
  • Posts: 406
  • Joined: 23-August 10

PHP (OOP) Login System Logic/Structure

Posted 23 August 2010 - 03:33 AM

I currently have a simple login system that ive coded.

It has all the features you would expect from a simple login system, however it will be extended over the next few months.
I am in the process of building a system for a long term project that will include/require this login system.

The way it is all layed out currently is messy and unorganised, however it works.

What I am trying to do is consolodate the whole thing into a well structured system and use this structure from this point forward for the rest of the system.

Currently the system is like so:

Things with forms, pull a form file and push to a class.
login
register
forgot password
activate account
edit profile

Things without a form, pull variables from the url/session and push to a seperate class.
logout
profiles
members list

As I said, very basic. Maybe a little too basic to worry about the structure and inner workings, however with the expansion I want to give the system, structure is going to be come very important.

I have deffinatly over looked somthing but am unsure as to what.

How would you structure a system like this?
(Forms seperate to process, process seperate to displayed info etc)

Ive looked at MVC but dont 100% understand how it would be practical in this situation, I think im at risk of over complicating things.

I am trying to stay away from using a structure like login.php, logout.php, register.php but maybe im avoiding the best solution?

I hope ive not confused you, thanks for your time.

Is This A Good Question/Topic? 0
  • +

Replies To: PHP (OOP) Login System Logic/Structure

#2 Dormilich  Icon User is offline

  • 痛覚残留
  • member icon

Reputation: 3524
  • View blog
  • Posts: 10,164
  • Joined: 08-June 10

Re: PHP (OOP) Login System Logic/Structure

Posted 23 August 2010 - 03:45 AM

things to consider:

- how do I make output (e.g. templates, what kind of templates, …)
your whole output system (the V of MVC) depends on that desicion.

- how do I handle data (save data to session/db/file/etc.)

if you code classes, don’t put too much in it. a class should only have one task. e.g. a Login class basically requires a login, a logout and a status method. saving data while logged in is dependent on your storage system and thus no concern of the Login class (although the storage system should interact with your Login class)

PS. are you using PHP 5.3?

This post has been edited by Dormilich: 23 August 2010 - 03:49 AM

Was This Post Helpful? 0
  • +
  • -

#3 PhunkRabbit  Icon User is offline

  • D.I.C Regular
  • member icon

Reputation: 81
  • View blog
  • Posts: 406
  • Joined: 23-August 10

Re: PHP (OOP) Login System Logic/Structure

Posted 23 August 2010 - 03:55 AM

Thanks for the quick reply Dormilich.

Yes I am currently running PHP 5.3 on a VPS and have access to the PHP.ini.
Was This Post Helpful? 0
  • +
  • -

#4 Dormilich  Icon User is offline

  • 痛覚残留
  • member icon

Reputation: 3524
  • View blog
  • Posts: 10,164
  • Joined: 08-June 10

Re: PHP (OOP) Login System Logic/Structure

Posted 23 August 2010 - 04:09 AM

when running PHP 5.3 you can use the namespaces to address the classes in their directories. (just that you know and can incorporate it)
Was This Post Helpful? 1
  • +
  • -

#5 PhunkRabbit  Icon User is offline

  • D.I.C Regular
  • member icon

Reputation: 81
  • View blog
  • Posts: 406
  • Joined: 23-August 10

Re: PHP (OOP) Login System Logic/Structure

Posted 23 August 2010 - 04:30 AM

ok, brilliant, thanks for the info.

Still interested in any counter opinions that anyone may have.
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1