I followed this guide as an attempt to write a login script for my hobby webpage.
Problem is when I want to incorporate it into my page, problems occur.
I’m trying to make an admin panel.
In the top of the frame I want the login form to be

When I log in, I’d like the Login form area to change into Logout fields.
My problem is that all cookie-related calls has to be done before the HTML code starts…
So:
- When you log in: content of the page should be displayed ( a simple include ).
- When you log in: login area changes into logout area, thus hiding the login fields and displaying name of user logged in…
- and when logging out: content and logout should disappear and show login fields again.
How can this be done (give examples like pseudo code)?
PS. Im not a PHP nerd, still learning.
You could write your login Data into your current session.
But don’t forget to call session_start() at the top of your code.
After that you check whether "$_SESSION["username"]" is set with your data. If so, you can change your content to whatever you like.
Example:
loginSuccessful() should be a method that checks whether your Login Data can be found in your database.
More information about sessions can be found here.