PHP - Need help

Discussion in 'Computer Programming, Emulation, and Game Modding' started by Waflix, Aug 4, 2011.

  1. Waflix
    OP

    Waflix El Psy Congroo

    Member
    638
    1
    Dec 17, 2010
    Netherlands
    I've been writing my site for a few days now, but my register and login system doesn't seem to work.
    The problem is that logging out doesn't work. When you click 'logout' you stay logged in!

    My system is based on a Dutch tutorial (click here) and I've made some adjustments so you can login at the homepage, and once you've been logged in, you will see a welcome message instead of the login form.
    My site can be found here: just click here.

    I don't think the problem is that you don't log out, but that it still displays the welcome message, even when you are already logged in.
    CODE// logout.php


    CODE// login.php


    ÂÂÂÂ
    ÂÂÂÂÂÂÂÂBlanco [Martijn]
    ÂÂÂÂÂÂÂÂ
    ÂÂÂÂ
    ÂÂÂÂ
    ÂÂÂÂÂÂÂÂ
    ÂÂÂÂÂÂÂÂÂÂÂÂ
    ÂÂÂÂÂÂÂÂÂÂÂÂLogin
    ÂÂÂÂÂÂÂÂÂÂÂÂ
     
  2. soulx

    soulx GBAtemp Legend

    Member
    10,130
    4,707
    Apr 4, 2009
    Canada
    You need to initialize the session first by calling,
    Code:
    session_start()
    1
     
  3. Issac

    Issac oh!

    Global Moderator
    GBAtemp Patron
    Issac is a Patron of GBAtemp and is helping us stay independent!

    Our Patreon
    5,048
    1,826
    Apr 10, 2004
    Sweden
     
  4. Waflix
    OP

    Waflix El Psy Congroo

    Member
    638
    1
    Dec 17, 2010
    Netherlands
    ^
    ^If you mean I should add that code to 'logout.php', then I get this:
    You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'LIMIT 1' at line 2[/p]

    ^ And, Issac, I deleted it succesfully, but it didn't solve the problem stated earlier in this post. But it was indeed unnecessary code.
     
  5. soulx

    soulx GBAtemp Legend

    Member
    10,130
    4,707
    Apr 4, 2009
    Canada
    CODE
    Try this instead.

    Also, you can check the syntax of your PHP, here.
     
  6. Issac

    Issac oh!

    Global Moderator
    GBAtemp Patron
    Issac is a Patron of GBAtemp and is helping us stay independent!

    Our Patreon
    5,048
    1,826
    Apr 10, 2004
    Sweden
    Ah, Checked a bit more now... It is like SoulSnatcher says... in a way...

    In the tutorial they change page, and exit the if-statement after they destroyed the session. You destroy it and then continue with the next..
    There, you'd have to start the session again i believe.

    EDIT: Wrote that before SoulSnatchers new response... What he say is probably better! [​IMG]
     
  7. Waflix
    OP

    Waflix El Psy Congroo

    Member
    638
    1
    Dec 17, 2010
    Netherlands
    The Syntax error is gone, but now the only problem is that there is a small mistake in the code, like a missing . ) ; ' or }
    Gone!

    And now it's always displaying "You didn't fill in a name!" because it doesn't know if you've already submitted the form or not. :')
    Gone! --> It is now completely working; yay!
     
  8. Issac

    Issac oh!

    Global Moderator
    GBAtemp Patron
    Issac is a Patron of GBAtemp and is helping us stay independent!

    Our Patreon
    5,048
    1,826
    Apr 10, 2004
    Sweden
    Great! Glad you got it sorted out! [​IMG]