Julius Posted April 5, 2011 Share Posted April 5, 2011 Hello, I'm doing something that looks like framework. It's my first serious "project". And now, I have a few questions: what basic functions are needed in MVC model class? Just tell me some functions, that could use, so I could try to code them. And the next question is... I'm going to create a login system for users. In my website there will be pages, that are visible for all visitors, and only for members. For example main website page should be visible for all visitors, but the page, where member can change his password, should be visible only for member. I know only one way to do this: allways and everywhere check if user is logged in. But isn't there smarter and simpler way? I hope you understood what I need. Sorry for bad english Quote Link to comment https://forums.phpfreaks.com/topic/232758-php-login-class-and-one-more-question/ Share on other sites More sharing options...
Psycho Posted April 5, 2011 Share Posted April 5, 2011 In my website there will be pages, that are visible for all visitors, and only for members. For example main website page should be visible for all visitors, but the page, where member can change his password, should be visible only for member. I know only one way to do this: allways and everywhere check if user is logged in. But isn't there smarter and simpler way? What is not simple/smart about checking if a user is logged in before displaying pages that require the user to be logged in? If you are storing a flag in the $_SESSION variable it is a simple task to check. Just include a file at the top of every page that requires the user to be logged in. That file would check if the user is logged in. If not, that file will redirect them to the login page and cancel execution of the rest of the script (which would have displayed the page requiring the user to be logged in). Quote Link to comment https://forums.phpfreaks.com/topic/232758-php-login-class-and-one-more-question/#findComment-1197237 Share on other sites More sharing options...
Julius Posted April 5, 2011 Author Share Posted April 5, 2011 this is a very good solution, BUT. My file starts like this: <?php Mynewclass extends Controller { function () { code } } ?>, so how should I include that file, or maybe you could give me an alternative solution? OOP is new for me, just started using. And my "framework" is pretty similar to codeigniter Quote Link to comment https://forums.phpfreaks.com/topic/232758-php-login-class-and-one-more-question/#findComment-1197286 Share on other sites More sharing options...
Nuxius Posted April 5, 2011 Share Posted April 5, 2011 I would make a new file called: checkuser.php in checkuser.php (you can also directly input this in all the pages you want to check user) <?php include('-the-place-you-have-stored-the-class-file.php'); $checkuser = new nameoftheclass(); $checkuser->name-of-the-function-under-the-class(); ?> Please correct me if i'm wrong, i'm new to PHP too. Quote Link to comment https://forums.phpfreaks.com/topic/232758-php-login-class-and-one-more-question/#findComment-1197293 Share on other sites More sharing options...
Julius Posted April 5, 2011 Author Share Posted April 5, 2011 hell yeah. a helper. I'm going to create my first helper. Thanks but the question about model class is still unanswered Quote Link to comment https://forums.phpfreaks.com/topic/232758-php-login-class-and-one-more-question/#findComment-1197297 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.