Help with this php stuff  | | |
June 18th, 2003, 08:39 PM
|
#1 (permalink)
| | Member
Join Date: Jun 2003
Posts: 99
|
Ok so Im working on this webpage engine type thing and what I want is so that every page will have the include for easy updating. So for navagation in this code I want it to be like if I had a link goto page1 then it would be domain.com/index.php?view=page1 and in the code it would know where to go and Im very confused and dont know a ton about php. Heres the code so far:
<? include("header.php"); ?>
<?
if ($_GET["error"] == "404") {
echo "404: page not found!<BR><BR>";
echo "<a href=index.php>main page</a>";
}
elseif ($_GET["view"] == "page1") {
include("page1.php");
}
elseif ($_GET["view"] == "page2") {
include("page2.php");
}
elseif ($_GET["view"] == "page3") {
include("page3.php");
}
elseif ($_GET["view"] == "page4") {
include("page4.php");
}
elseif ($_GET["view"] == "page5") {
include("page5.php");
}
elseif ($_GET["view"] == "page6") {
include("page6.php");
}
elseif ($_GET["view"] == "page7") {
include("page7.php");
}
elseif ($_GET["view"] == "page8") {
include("page8.php");
}
else {
include("main.php");
}
?>
<? include("footer.php"); ?> |
| |
June 19th, 2003, 01:04 AM
|
#2 (permalink)
| | Banned
Join Date: Oct 2001
Posts: 447
|
what if they _POST?
Cannot use includes this way, unless PHP changed, because, includes processed before other PHP code.
If your page takes all requests, just pocess in same PHP? |
| |
June 19th, 2003, 02:32 AM
|
#3 (permalink)
| | Member
Join Date: Oct 2001 Location: Palatine, IL
Posts: 375
|
Actually, PHP will handle includes that way.
What errors are you recieving when someone loads that page? |
| |
June 19th, 2003, 10:30 PM
|
#4 (permalink)
| | Member
Join Date: Jun 2003
Posts: 99
|
I get this: Notice: Undefined index: view in D:\blah\blah\index.php on line blah |
| |
June 19th, 2003, 10:35 PM
|
#5 (permalink)
| | Real gangstas sip on Yacc
Join Date: Oct 2001 Location: Suckas-ville
Posts: 4,552
|
Try making them like so
$_GET[view] == "page8")
Remove the quotes from view and see if that works for you.
Jkrohn
__________________
Signatures blow hard
If your signature contains an ad of any kind, congratulations, you're on my ignore list.
|
| |
June 20th, 2003, 10:01 PM
|
#6 (permalink)
| | Banned
Join Date: Oct 2001
Posts: 447
|
oops, you're right, was thinking of ASP, or JSP...
Or maybe require()?
"Prior to PHP 4.0.2, the following applies: require() will always attempt to read the target file, even if the line it's on never executes."
Anyway, error seems to be if statement.
Try posted and:
$_GET['view'] == 'page8')
view is a form field, not $var, need ' |
| |
June 21st, 2003, 03:58 AM
|
#7 (permalink)
| | Member
Join Date: Jun 2003
Posts: 99
|
Nope....it still comes up with the same error. |
| |
June 21st, 2003, 04:22 PM
|
#8 (permalink)
| | Member
Join Date: Jun 2003
Posts: 99
|
I asked this in a different forum and they didnt say much and took like a day to answer but they said to use switch case but I dont know anything about it. |
| |
June 21st, 2003, 04:37 PM
|
#9 (permalink)
| | Real gangstas sip on Yacc
Join Date: Oct 2001 Location: Suckas-ville
Posts: 4,552
| Quote: |
view is a form field, not $var, need '
| False the ' is not necessary 
Swich statement works as follows:
switch($_GET[view]) {
case 'page1': include("page1.php"); break;
case 'page2': include("page2.php"); break;
case 'page3': include("page3.php"); break;
etc...
}
Jkrohn |
| |
June 21st, 2003, 05:05 PM
|
#10 (permalink)
| | Member
Join Date: Jun 2003
Posts: 99
|
I still get an error but now its:
Notice: Use of undefined constant view - assumed 'view' in blah on line blah
and
Notice: Undefined index: view in blah on line blah |
| | | Thread Tools | Search this Thread | | | | |
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | | | | Most Active Discussions | | | | | Recent Discussions  | | | | | |