PHP question about global variables and form requests

Posted by user220201 on Stack Overflow See other posts from Stack Overflow or by user220201
Published on 2010-12-21T08:29:41Z Indexed on 2010/12/21 8:54 UTC
Read the original article Hit count: 241

Filed under:
|
|

Hi,

This is probably a stupid question but will ask anyway sine I have no idea.

I have written basic php code which serve forms. Say I have a login page and I serve it using the login.php page and it will be called in the login.html page like this -

<form action="login.php" method="post">

By this it is also implied that every POST needs its own php file, doesn't it? This kind of feels weird. Is there a way to have a single file, say code.php, and just have each of the forms as functions instead?

EDIT: Specifically, say I have 5 forms that are used one after the other in my application. Say after login the user does A, B, C and D tasks each of which are sent to the server as a POST request. So instead of having A.php, B.php, C.php and D.php I would like to have a single code.php and have A(), B(), C() and D() as functions. Is there a way to do this?

Also on the same note, how do I deal with say a global array (e.g. an array of currently logged in users) across multiple forms? I want to do this without writing to a DB. I know its probably better to write to a DB and query but is it even possible to do it with a global array? The reason I was thinking about having all the form functions in one file is to use a global array.

Thanks, - Pav

© Stack Overflow or respective owner

Related posts about php5

Related posts about global-variables