Page 1 of 1
Invoking a new page
Posted: Sat Apr 17, 2010 11:16 pm
by JackD
At present, everything we do does an "echo xxxx" to put html code on the page to be executed by a user action. Now, if a page is invoked with a particular set of parameters, after some processing, we need to invoke a different web page with the calculated values. For example, we want to be able to execute something like "detail.php?Page=1" where "detail.php" is a web page other than the one currently displayed.
How can we do that?
Re: Invoking a new page
Posted: Sun Apr 18, 2010 12:02 am
by requinix
Kinda confusing, but
You can have the "main" page do some logic and include the appropriate page.
Code: Select all
<?php
if ($some_condition_is_true) {
include "page1.php";
} else if ($some_other_condition_is_true) {
include "page2.php";
} else {
include "page3.php";
}
Re: Invoking a new page
Posted: Sun Apr 18, 2010 11:21 am
by JackD
Thanks!!
Re: Invoking a new page
Posted: Sun Apr 18, 2010 11:32 am
by JackD
That did not work for two reasons:
1. It actually did include the page on top of the current page. This resulted in two headers, two sidebars, etc.
2. It did not allow any arguments to be passed as it tried to use the entire string as a file name. Eg, "detail.php?KW=sam" became the entire file name.
Thanks for trying, though.
Re: Invoking a new page
Posted: Sun Apr 18, 2010 5:10 pm
by requinix
1. Then
(a) strip the everything but the content itself from each page and put the rest (headers, etc) in a different place, or
(b) Only include one file.
2. You don't include("detail.php?KW=sam"). Just "detail.php".
Re: Invoking a new page
Posted: Sun Apr 18, 2010 6:36 pm
by JackD
So, you are saying there is no way in PHP to dynamically, on-the-fly, invoke a new page ala "detail.php?KW=sam&PG=2"?
Re: Invoking a new page
Posted: Sun Apr 18, 2010 7:04 pm
by requinix
JackD wrote:So, you are saying there is no way in PHP to dynamically, on-the-fly, invoke a new page ala "detail.php?KW=sam&PG=2"?
You don't "invoke" files that way.
So I guess $_GET doesn't already have KW=sam&PG=2? Then put it there yourself.
Code: Select all
$_GET["KW"] = "sam";
$_GET["PG"] = 2;
include "detail.php";