RE: [PHP] Includes
| From: | Christoph Starkmann | Date: | Fri, 05 Apr 2002 11:32:02 +0000 |
| Subject: | RE: [PHP] Includes | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-91694@lists.php.net to get a copy of this message | ||
> Well, I think I should give a better explanation. I have been
> seeing a lot
> of scripts that appear to be on multiple pages. For example:
> You open file.php, and you are greeted with a form asking
> your name. You
> give in your name and then submit the form. After you submit
> the form you
> would normally get a new page saying your name has been
> stored or something
> like that. This time, that also happens BUT you do not go to
> a new separate
> file. The URL in your browser is still on file.php, however
> the form that
> was there before is GONE and you see a totally new page. I am
> asking how
> something like this can be done. If it will help I can attach
> a file that
> does this.
Yes, and exactly this is what I told you ;)
I've got one page, let's say "main.php".
This page is looking for a var, let's say called "$curAction";
$curAction is not present the script knows that you're new to
this site and calls a function called "displayWelcome" (wherever
this function is defined ;)).
<?php
$curAction = $HTTP_POST_VARS["curAction"];
switch ($curAction)
{
case "displayForm1":
{
displayForm1();
break;
}
case "displayForm2":
{
displayForm2();
break;
}
case "logoff":
{
displayGoodbye();
logout();
break;
}
// And so on...
}
function displayForm1()
{
?><form><!-- html goes here --></form><?php
}
// ...and so forth
?>
So this switch casecade handles what content is to be displayed,
which looks as if you where getting different pages...
Better now?
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
-----