Advertisement
If you have a new account but are having problems posting or verifying your account, please email us on hello@boards.ie for help. Thanks :)
Hello all! Please ensure that you are posting a new thread or question in the appropriate forum. The Feedback forum is overwhelmed with questions that are having to be moved elsewhere. If you need help to verify your account contact hello@boards.ie

PHP Login / Logout Question

Options
  • 20-05-2009 1:24pm
    #1
    Registered Users Posts: 242 ✭✭


    Hi All,

    Being extremely new to PHP and mySQL i need some help.

    I have setup a login form connected to an SQL database for users to login.
    That all works fine and they are redirected to the customer area page.

    Where i need help, and i know this is probably something basic is, when the customer logs in, the div at the top of the page containing the login form to be hidden and to be replaced by a div with the message "welcome (user) " and a logout button.

    Any help would be appriciated.

    Thanks in advance ! :cool:


Comments

  • Registered Users Posts: 1,127 ✭✭✭smcelhinney


    I think what you're talking about is AJAX driven. The idea being, the user logs in, the processing is done in the background, and the response is sent back.

    Google "php ajax login", that should help. Here's a good example, which also shows the logic involved.

    http://woork.blogspot.com/2007/10/login-using-ajax-and-php.html


  • Registered Users Posts: 242 ✭✭SD1990


    Thanks for reply!

    But i was hoping to stick with the SQL way as ive only grasped that now.

    Is their any way to code the 2 divs for one to be to be visible:true , and the other to be visible:false upon login ?


  • Registered Users Posts: 7,518 ✭✭✭matrim


    You're best option would be to do this server side, based on the session login information

    When printing out the page to display if the user is logged in, print the welcome, if not print the welcome e.g.
    if($loggedIn)
    {
       //print welcome user 
    }
    else
    {
       //print login form
    }
    


  • Registered Users Posts: 6,511 ✭✭✭daymobrew


    SD1990 wrote: »
    But i was hoping to stick with the SQL way as ive only grasped that now.
    AJAX is not a replacement for SQL so your learning will not be a loss.

    AJAX is mainly used to change the front end without the user having to refresh the page. I recommend implementing without AJAX features - especially as you are very new to PHP and MySQL (I know PHP/MySQL != HTML). You can add such 'fancy' functionality later.


Advertisement