SitePoint Sponsor

User Tag List

Results 1 to 6 of 6
  1. #1
    SitePoint Guru laflair13's Avatar
    Join Date
    Nov 2004
    Location
    TN
    Posts
    626
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    URGANT - Please help with members area

    Hey all, I just found out today that my members area is coming up in the search results. Well when people click on the link it takes them directly to the members section without having to login.

    What can I do to make it to where they have to login when going to that section of my site from search engines.
    Thanks In Advance

    David

  2. #2
    Non-Member Kalon's Avatar
    Join Date
    Aug 2010
    Location
    At my computer
    Posts
    2,012
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    make sure your authentication script sets a session variable when a user logs in.

    then at the top of every member page, check if that session variable exists and is set to the correct value before proceeding with the rest of the page load.

    when a visitor from a search engine clicks a member page link the session variable won't exist and so the page will not load.

  3. #3
    SitePoint Addict svcghost's Avatar
    Join Date
    Oct 2010
    Posts
    288
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by laflair13 View Post
    Hey all, I just found out today that my members area is coming up in the search results. Well when people click on the link it takes them directly to the members section without having to login.

    What can I do to make it to where they have to login when going to that section of my site from search engines.
    Check if the user has a logged in session before showing the content of those pages. If they do not, redirect them to a page they are allowed access to.

  4. #4
    SitePoint Guru laflair13's Avatar
    Join Date
    Nov 2004
    Location
    TN
    Posts
    626
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Gotcha, Which piece of the code do I put on the members index page?

    Would I need to put something like this on the page

    Code:
    <?PHP
    //check that the form fields are not empty, and redirect back to the login page if they are
    elseif (empty($username) || empty($password)) {
    header( "Location: http://www.researchanyone.com/login.html" );
    }
    else{
    ?>
    Thanks In Advance

    David

  5. #5
    SitePoint Addict svcghost's Avatar
    Join Date
    Oct 2010
    Posts
    288
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    You can write the code in a separate file and then use PHP include to put it in the member index page. So have it check if there is an active session on that user's browser in which a member in the database is logged on. If it is, display the page normally. If it isn't, don't display the page and just redirect the user to the regular index page or something using PHP header.

  6. #6
    SitePoint Guru laflair13's Avatar
    Join Date
    Nov 2004
    Location
    TN
    Posts
    626
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I have the check_login.php page, and sorry for the newb question, but how can I put that in a members page.

    Like an include tag?
    Thanks In Advance

    David


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
  •