»
 

Go Back   ResellerRatings Store Ratings > ResellerRatings Forums > Tech Support

Reply
 
LinkBack Thread Tools Display Modes
Old 06-18-2003, 05:39 PM   #1 (permalink)
Registered User
 
Join Date: Jun 2003
Posts: 78
SplitCo is on a distinguished road
Help with this php stuff

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"); ?>

SplitCo is offline   Reply With Quote
Old 06-18-2003, 10:04 PM   #2 (permalink)
Banned
 
qball's Avatar
 
Join Date: Oct 2001
Posts: 447
qball is on a distinguished road
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?
qball is offline   Reply With Quote
Old 06-18-2003, 11:32 PM   #3 (permalink)
Registered User
 
gothic's Avatar
 
Join Date: Oct 2001
Location: Palatine, IL
Posts: 375
gothic is on a distinguished road
Actually, PHP will handle includes that way.

What errors are you recieving when someone loads that page?
gothic is offline   Reply With Quote
Old 06-19-2003, 07:30 PM   #4 (permalink)
Registered User
 
Join Date: Jun 2003
Posts: 78
SplitCo is on a distinguished road
I get this: Notice: Undefined index: view in D:\blah\blah\index.php on line blah
SplitCo is offline   Reply With Quote
Old 06-19-2003, 07:35 PM   #5 (permalink)
Registered User
 
jkrohn's Avatar
 
Join Date: Oct 2001
Location: Champaign, IL
Posts: 3,253
jkrohn is on a distinguished road
Send a message via ICQ to jkrohn Send a message via AIM to jkrohn Send a message via Yahoo to jkrohn
Try making them like so
$_GET[view] == "page8")

Remove the quotes from view and see if that works for you.

Jkrohn
__________________
Jkrohn
jkrohn is offline   Reply With Quote
Old 06-20-2003, 07:01 PM   #6 (permalink)
Banned
 
qball's Avatar
 
Join Date: Oct 2001
Posts: 447
qball is on a distinguished road
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 '
qball is offline   Reply With Quote
Old 06-21-2003, 12:58 AM   #7 (permalink)
Registered User
 
Join Date: Jun 2003
Posts: 78
SplitCo is on a distinguished road
Nope....it still comes up with the same error.
SplitCo is offline   Reply With Quote
Old 06-21-2003, 01:22 PM   #8 (permalink)
Registered User
 
Join Date: Jun 2003
Posts: 78
SplitCo is on a distinguished road
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.
SplitCo is offline   Reply With Quote
Old 06-21-2003, 01:37 PM   #9 (permalink)
Registered User
 
jkrohn's Avatar
 
Join Date: Oct 2001
Location: Champaign, IL
Posts: 3,253
jkrohn is on a distinguished road
Send a message via ICQ to jkrohn Send a message via AIM to jkrohn Send a message via Yahoo to jkrohn
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
__________________
Jkrohn
jkrohn is offline   Reply With Quote
Old 06-21-2003, 02:05 PM   #10 (permalink)
Registered User
 
Join Date: Jun 2003
Posts: 78
SplitCo is on a distinguished road
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
SplitCo is offline   Reply With Quote
Reply




Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Most Active Discussions

Recent Discussions

All times are GMT -6. The time now is 02:56 PM.