How to protect certain part of a page using PHP Include ?

Discussion in 'Setting-up protection' started by quecoder, Apr 22, 2010.

  1. quecoder

    quecoder New Member

    Joined:
    Apr 20, 2010
    Messages:
    1
    Hello ,
    I want to just hide a single paragraph inside my custom built website using PHP Include and show it for members only ....



    Can you help me ! :>
  2. thehpmc

    thehpmc Member

    Joined:
    Aug 24, 2006
    Messages:
    901
    One way would be to check if the visitor is logged into aMember and then simply include the 'include' only if they are logged in using an if statement.
  3. alexander

    alexander Administrator Staff Member

    Joined:
    Jan 8, 2003
    Messages:
    6,279
    Here is example:
    Code:
    // Should be placed at the top of the file
    session_start(); 
    
    ....... 
    
    if($_SESSION['_amember_id'] && $_SESSION['amember_user'][status]){
    // User logged in and active
    include "/path/to/file";
    }
    
    
  4. lacicrips

    lacicrips New Member

    Joined:
    Jan 17, 2010
    Messages:
    9
    I used this on my php page:

    When members login it says:

    They can log in to amember quite alright but not to the protected page.
  5. mwaqas_84

    mwaqas_84 New Member

    Joined:
    Sep 16, 2010
    Messages:
    1
    it worked for me except i changed $_SESSION['amember_user'][status]) to
    $_SESSION['_amember_user'][status]){
    Pleaser note the difference between
    amember_user and _amember_user'

Share This Page