Give help. Get help.

  • # April 4, 2009 at 3:03 pm


    I’m working on implementing a basic php registration and login script from I have it up and running on my server, and it works fine. However, I’m a little uncertain how to protect a page from non-registered users. Once a user registers, they can access a certain page.

    What I have in mind is simply allowing a user to register, and once registered, allowing that user access to another form where that information entered into that form is entered into the database under that users name. Like a contest where you have to be registered to play the contest, and once you are registered you can submit your answers.

    I have the login authentication and registration working, but am stuck on how to do the above.

    Here’s the main.php script that a user is greeted with:

    < ? /** * Main.php * * This is an example of the main page of a website. Here * users will be able to login. However, like on most sites * the login form doesn't just have to be on the main page, * but re-appear on subsequent pages, depending on whether * the user has logged in or not. * * Written by: Jpmaster77 a.k.a. The Grandmaster of C++ (GMC) * Last Updated: August 26, 2004 */ include("include/session.php"); ?>

    Jpmaster77’s Login Script

    < ? /** * User has already logged in, so display relavent links, including * a link to the admin center if the user is an administrator. */ if($session->logged_in){
    echo “

    Logged In

    echo “Welcome $session->username, you are logged in.

    .”[username”>My Account]   ”
    .”[Edit Account]   “;
    echo “[Admin Center]   “;
    echo “[Logout]”;


    < ? /** * User not logged in, display the login form. * If user has already tried to login, but errors were * found, display the total number of errors. * If errors occurred, they will be displayed. */ if($form->num_errors > 0){
    echo ““.$form->num_errors.” error(s) found“;

    Username: value(“remember”) != “”){ echo “checked”; } ?>>
    Remember me next time     

    [Forgot Password?]
    Not registered? Sign-Up!

    < ? } /** * Just a little page footer, tells how many registered members * there are, how many users currently logged in and viewing site, * and how many guests viewing site. Active users are displayed, * with link to their user information. */ echo "

    echo “Member Total: “.$database->getNumMembers().”
    echo “There are $database->num_active_users registered members and “;
    echo “$database->num_active_guests guests viewing the site.




    Any suggestions?

Viewing 1 post (of 1 total)

You must be logged in to reply to this topic.