PHP - Need help

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

Aug 4, 2011

PHP - Need help by Waflix at 1:37 PM (604 Views / 0 Likes) 7 replies

  1. Waflix
    OP

    Member Waflix El Psy Congroo

    Joined:
    Dec 17, 2010
    Messages:
    638
    Country:
    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

    Member soulx GBAtemp Legend

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

    Member Issac Mini-mod

    Joined:
    Apr 10, 2004
    Messages:
    4,454
    Location:
    Sweden
    Country:
    Sweden
     
  4. Waflix
    OP

    Member Waflix El Psy Congroo

    Joined:
    Dec 17, 2010
    Messages:
    638
    Country:
    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

    Member soulx GBAtemp Legend

    Joined:
    Apr 4, 2009
    Messages:
    10,130
    Country:
    Canada
    CODE
    Try this instead.

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

    Member Issac Mini-mod

    Joined:
    Apr 10, 2004
    Messages:
    4,454
    Location:
    Sweden
    Country:
    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

    Member Waflix El Psy Congroo

    Joined:
    Dec 17, 2010
    Messages:
    638
    Country:
    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

    Member Issac Mini-mod

    Joined:
    Apr 10, 2004
    Messages:
    4,454
    Location:
    Sweden
    Country:
    Sweden
    Great! Glad you got it sorted out! [​IMG]
     

Share This Page