Invoking a new page

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
JackD
Forum Commoner
Posts: 62
Joined: Sat Dec 12, 2009 6:25 pm

Invoking a new page

Post 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?
User avatar
requinix
Spammer :|
Posts: 6617
Joined: Wed Oct 15, 2008 2:35 am
Location: WA, USA

Re: Invoking a new page

Post 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";
}
JackD
Forum Commoner
Posts: 62
Joined: Sat Dec 12, 2009 6:25 pm

Re: Invoking a new page

Post by JackD »

Thanks!!
JackD
Forum Commoner
Posts: 62
Joined: Sat Dec 12, 2009 6:25 pm

Re: Invoking a new page

Post 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.
User avatar
requinix
Spammer :|
Posts: 6617
Joined: Wed Oct 15, 2008 2:35 am
Location: WA, USA

Re: Invoking a new page

Post 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".
JackD
Forum Commoner
Posts: 62
Joined: Sat Dec 12, 2009 6:25 pm

Re: Invoking a new page

Post 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"?
User avatar
requinix
Spammer :|
Posts: 6617
Joined: Wed Oct 15, 2008 2:35 am
Location: WA, USA

Re: Invoking a new page

Post 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";
Post Reply