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?
Invoking a new page
Moderator: General Moderators
Re: Invoking a new page
Kinda confusing, but
You can have the "main" page do some logic and include the appropriate page.
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
Thanks!!
Re: Invoking a new page
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.
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
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".
(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
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
You don't "invoke" files that way.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"?
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";