Jump to content

PHP Login Script Using OOP


new@php

Recommended Posts

Hey Guys,

 

I need some help please.

 

I have taken on a project which is slightly beyond me at the moment! I have been asked to complete a PHP Login Script that by the looks of it uses OOP.

 

I have been given some files in which the script has been set up by it needs to be completed to do the following:

 

User arrives at Login >>> User Logins in Successfully >> create User object and save in $_SESSION >> redirect to homepage >>> homepage retrieves User from session and displays "welcome username"

 

If there no login registered then the user should be redirect to the login page. the same should be done if the username is not recognized.

 

I have the following files on and scripts:

 

index.php

 

Code:

 

	
<div id="Header">Header</div>
<div id="Body">[WELCOME]</div>
<div id="Footer">Footer</div>

 

 

 

Login.php

 

Code:

<div id="Header">Header</div>
<div id="Body">[LOGIN FORM]</div>
<div id="Footer">Footer</div>

 

 

Both these pages also contain:

 

PHP Code:

<?php
require '_includes/_includes.php';
?>

 

 

These include files are:

 

User.php

 

PHP Code:

<?php
class User  {
    var $id;
    var $username;
    var $password;
    var $firstName;
    var $lastName;
    var $active;
    var $email;
    
    function User($row) {
        $this->username = $row['username'];
    }
}
?>

 

 

and UserManager.php

 

PHP Code:

<?php
class UserManager {
    
    function UserManager() {
    }
    
    function login ($username, $password) {
        return new User ();
    }
    
    function checkUserLoggedIn () {
        return false;
    }
}
?>

 

 

Can anyone help me out here with some possible solutions and maybe an explanation? As I'm kind of at a loss!

 

I know a form is required which is straightforward enough and a login script but how do i integrate the current User.php and Usermanager.php files?

 

Many thanks!

 

Seb

Link to comment
https://forums.phpfreaks.com/topic/65480-php-login-script-using-oop/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.