Page 1 of 1

concerning States

Posted: Tue Jun 08, 2010 4:06 pm
by queirozf
hello. I hope someone can help me with this.

i have this page, called file_pool.php, which is where logged users can access uploaded files by other members.

However, the user should only be able to view the files ONCE he/she has been found to be in the DB.

SO it goes like this

*if the user isnt logged in yet*

Code: Select all

if (!isset($_SESSION["user"])) { #show html forms and etc so the user can log in}
but if the user IS already logged in (i.e. $_SESSION["user"] is SET) then i want to show then something else...

Code: Select all

else{ #show the files the user can download}
But the catch is: say a user isn't logged in yet. So he goes, fills out the html forms and hits "Submit". Suppose his username AND password match.
I would like php to, once the user has been authenticated, make some sort of refresh on the page, so it now shows the members-only area, namely the files. But without me having to hit refresh on my browser.

I looked into some answers for this and came up with the header() function, but im not sure how i should use it, or maybe is there some other way?

thanks in advance hope you understood

Re: concerning States

Posted: Tue Jun 08, 2010 4:22 pm
by phdatabase
If you submit a form the page will automatically refresh, or at least will have that effect, to make the form submission available to the page.

Re: concerning States

Posted: Tue Jun 08, 2010 5:04 pm
by queirozf
it still doesnt.... As you've seen, my .php file is split into two cases: #1 if the user is not logged in, #2 if the user is logged in (i.e. Session Variables have been set)

what i would LIKE to happen is:

step1: user comes, isnt logged in (username and password forms are visible)
step2: user fills in forms, hits submit
step3: forms disappear, member-only area is shown.

i read something that made me think this would fall under the "one component querying" umbrella but it doent help me much.

thank you

Re: concerning States

Posted: Tue Jun 08, 2010 5:08 pm
by John Cartwright
Generally, you want to put all your processing code prior to outputting any HTML. Therefore, on the request that authenticates them, further on in the code when you output the member section or login, you have the correct info to display.