PDA

View Full Version : E_notice: a little help on index.php?page=any


kazuki
09-16-2002, 09:57 AM
E_notice: a little help on index.php?page=any
HI,

I have constructed links to my pages but I can't solve this little
problem something like index.php?page=anything. The links worked fine. But in the main index.php there is a little error.

Notice: Undefined index: page in C:\My Documents\dualnew\index.php on line 2

I don't know to solve it.

<?php
switch($_GET['page']) {
case "page1":
include('page1.php');
break;
case "page2":
include('page2.php');
break;
default:
require_once('index.inc'); //this will be the opening page
}
?>


Suggestions anyone?

mordred
09-16-2002, 03:10 PM
Are you calling that page like C:\My Documents\dualnew\index.php, because if so there is not GET parameter appended to the URL, and PHP moans that you try to access an undefined array index.

Try it with

C:\My Documents\dualnew\index.php?page=page1

and see if that's solving the issue. Be also very careful when doing such a file include depending on GET parameters.

kazuki
09-17-2002, 09:24 AM
Hi,

the C:\My Documents\dualnew\index.php?page=page1
worked fine but what if the user edits the
url to it's default page like index.php? I get still
an

e_notice:undefined index.......

Is there another way to solve this problem?

Thanks.

mordred
09-17-2002, 01:37 PM
Sorry, I can't follow you on your last response. The user edits the php file or does he use a different GET parameter? Please be more elaborate on your problem, and post the complete error message. And describe also exactly what you did to reproduce the error and what you expected the script to do instead.

brothercake
09-17-2002, 01:51 PM
You can determine the existence of a get variable like this:

if ( isset($_GET['page']) ) {