RE: [PHP] Includes
| From: | Christoph Starkmann | Date: | Fri, 05 Apr 2002 10:34:52 +0000 |
| Subject: | RE: [PHP] Includes | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-91680@lists.php.net to get a copy of this message | ||
Hi Sebastian!
> Lately I have noticed many scripts that all consist of one
> file even though
> they create the appearance of many pages. For example, you would open
> setup.php and a form would appear. Then after you complete
> the form a new
> page appears with the results of your form, however the URL is still
> setup.php. So basically you can make complicated forms span
> only one file
> instead of having separate file to gather, display and save
> the data, how is
> this done?
You can handle the HTML-output from within any functions. What I am doing
normally is the following.
I got one page, let's say main.php
When calling this page I pass it a variable that tells main.php
which function to execute ("printForm", "submitForm", "changeDB" etc.)
This is done by a simple switch-cascade.
Now I'm organizing my functions properly in different include-files,
let's say "displayFuncs.php", "dbFuncs.php" etc..
And IMHO anything is much more clean and relaxed like this ;)
On the other hand, if you connect to a db etc. you only have to
write the code for the db_connect only one time (I include this, too).
Was this what you wanted to know?
Cheers,
Kiko
-----
It's not a bug, it's a feature.
christoph starkmann
mailto:kiko@nfq.de
http://www.fh-augsburg.de/~kiko
ICQ: 100601600
-----