SitePoint Sponsor

User Tag List

Results 1 to 3 of 3
  1. #1
    Non-Member
    Join Date
    Apr 2007
    Posts
    224
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    What makes this page protected?

    I've got a log-in script program with a protected page feature.
    For my education, what makes this page protected?
    Essentially, I just want to learn "How does it worK? the protection, I mean. Thanks. Heres the page code:


    Code:
    <?php
    /**
    *   @file: protected_content_example.php
    *   @description:	protected content page example
    */
    	session_start();
    	include_once "db_config.php";
    	include_once "classes/system.php";
    	include_once "classes/account.php";
    	include_once "classes/account_type.php";
    	include_once "classes/tools.php";
    	
    	$account = new account($system);
    	$acount_type = new account_type($system);
    	$account_type_id = $account->get_account_type_id();
    	$account_type_title = $acount_type->get_account_type_title($account_type_id);
    	
    	if ($account->check_login() == false) {
    		// redirect to index page if user not loged in
    		header("Location:index.php");	
    	}
    		
    	
    	
    ?>
    
    <html>
    <body>
    <table align="center">
    	<tr><td align="center"><b>User protected page for not free accounts.</b></td></tr>
    	<tr><td align="center">membership type: <b><?=$account_type_title ?></b></td></tr>
    	<tr><td align="center">protected content page.</td></tr>
    </table>
    </body>
    </html><?php
    /**
    *   @file: protected_content_example.php
    *   @description:	protected content page example
    */
    	session_start();
    	include_once "db_config.php";
    	include_once "classes/system.php";
    	include_once "classes/account.php";
    	include_once "classes/account_type.php";
    	include_once "classes/tools.php";
    	
    	$account = new account($system);
    	$acount_type = new account_type($system);
    	$account_type_id = $account->get_account_type_id();
    	$account_type_title = $acount_type->get_account_type_title($account_type_id);
    	
    	if ($account->check_login() == false) {
    		// redirect to index page if user not loged in
    		header("Location:index.php");	
    	}
    		
    	
    	
    ?>
    
    <html>
    <body>
    <table align="center">
    	<tr><td align="center"><b>User protected page for not free accounts.</b></td></tr>
    	<tr><td align="center">membership type: <b><?=$account_type_title ?></b></td></tr>
    	<tr><td align="center">protected content page.</td></tr>
    </table>
    </body>
    </html>

  2. #2
    SitePoint Member
    Join Date
    Apr 2006
    Posts
    22
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    You should check the logic behind the check_login method of the Account class.

    This is what actually protects the page:
    PHP Code:
        if ($account->check_login() == false) {
            
    // redirect to index page if user not loged in
            
    header("Location:index.php");    
        } 

  3. #3
    SitePoint Evangelist
    Join Date
    Aug 2005
    Posts
    453
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    You simply have to have a members account and pass the login to view the page. If not you get redirected to the index page.
    Computers and Fire ...
    In the hands of the inexperienced or uneducated,
    the results can be disastrous.
    While the professional can tame, master even conquer.


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •