How to make a database-driven website?

Discussion in 'MySQL' started by cipals15, Nov 28, 2008.

  1. #1
    I have successfully made a database and a php script where users can register for an account assuming that all entries are correct. I also made a javascript code the validates the form (but not working. so i stopped for a moment).

    My database has fields:

    id INT NOT NULL AUTO_INCREMENT,
    username VARCHAR(20) NOT NULL,
    password VARCHAR(20) NOT NULL,
    email VARCHAR(20) NOT NULL,

    I have a links tab on my homepage:

    Login | Logout | Register | My Profile

    The problem is:

    1. I want to show both Login | Register if the user hasn't login.
    2. I want to show Logout | My Profile on the tab if the user has login.

    My solution:
    I created 2 separate pages for both problems.

    But more problems have risen:

    1. how can i determine if the user has logged in?
    2. Should i add another field to determine the status of the user?

    If you have any recommended script or solution, just feel free to reply to this thread. As a beginner in PHP and MySQL, my knowledge is not that broad. Thank you.
     
    cipals15, Nov 28, 2008 IP
  2. Colbyt

    Colbyt Notable Member

    Messages:
    3,224
    Likes Received:
    185
    Best Answers:
    0
    Trophy Points:
    210
    #2
    A database field is not used for this. Sessions are used.

    After the login the variable (token) is carried forward. This will allow you to have only one page where If logged in show these links and if not show these.

    I can't post it tonight but will check the thread tomorrow. Maybe a more awake person will come along between now and then. :)
     
    Colbyt, Nov 28, 2008 IP