home hardware prices news articles forums photos user reviews
Go Back   Tech Support Forums - TechIMO.com > PC Hardware and Tech > Webmastering and Programming
Ask a Tech Support Question (free)!

Help with this php stuff

Reply
Get bargains at  »  Dealighted.com
 
Thread Tools Search this Thread
Currently Active Users: 1654
Discussions: 200,924, Posts: 2,379,117, Members: 246,290
Old June 18th, 2003, 08:39 PM   Digg it!   #1 (permalink)
Member
 
Join Date: Jun 2003
Posts: 99
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 June 19th, 2003, 01:04 AM     #2 (permalink)
Banned
 
qball's Avatar
 
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?
qball is offline   Reply With Quote
Old June 19th, 2003, 02:32 AM     #3 (permalink)
Member
 
gothic's Avatar
 
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?
gothic is offline   Reply With Quote
Old 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
SplitCo is offline   Reply With Quote
Old June 19th, 2003, 10:35 PM     #5 (permalink)
Real gangstas sip on Yacc
 
jkrohn's Avatar
 
Join Date: Oct 2001
Location: Suckas-ville
Posts: 4,552
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
__________________
Signatures blow hard
If your signature contains an ad of any kind, congratulations, you're on my ignore list.
jkrohn is offline   Reply With Quote
Old June 20th, 2003, 10:01 PM     #6 (permalink)
Banned
 
qball's Avatar
 
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 '
qball is offline   Reply With Quote
Old June 21st, 2003, 03:58 AM     #7 (permalink)
Member
 
Join Date: Jun 2003
Posts: 99
Nope....it still comes up with the same error.
SplitCo is offline   Reply With Quote
Old 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.
SplitCo is offline   Reply With Quote
Old June 21st, 2003, 04:37 PM     #9 (permalink)
Real gangstas sip on Yacc
 
jkrohn's Avatar
 
Join Date: Oct 2001
Location: Suckas-ville
Posts: 4,552
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 is offline   Reply With Quote
Old 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
SplitCo is offline   Reply With Quote
Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Most Active Discussions
Is It Just Me? (2862)
Obama the Muslim (14)
California Passes Anti-Flat-HDTV Le.. (39)
Is the PSU I received dead? (10)
windows vista security holes (9)
Foreign voltage (10)
HIS HD5770 graphic card question (15)
Print spooler problem (13)
Install XP pro and a Vista laptop ?.. (9)
Dept. of HS: NSA 'Helped' Develop V.. (15)
A good PSU? (10)
New Computer wont recognize XP disc (7)
Ideal cheap graph card for PC-Gamin.. (15)
EVGA 9800 gtx help with finding a g.. (8)
Recent Discussions
Wireless Router+Cable Modems and Much.. (0)
Optical Audio A-B Switch (1)
windows vista security holes (9)
Fire in DVD (0)
radeon x850xt platinum & shader 3 (2)
The NTDVM CPU has encountered an ille.. (24)
[F@H SPAM 11/16/09] ! 1/2 months to r.. (34)
Wireless speakers for PC? (11)
Print spooler problem (13)
Help getting around port 80 for camer.. (2)
Display shows 3x5 inch in middle of s.. (3)
monitor will not turn on at all, (1)
World's largest Monopoly Game using G.. (331)
Foreign voltage (10)
FiOS modem/router interfering with ne.. (7)
Browsers wont load websites (2)
Virus Doctor Popup? (1)
Dept. of HS: NSA 'Helped' Develop Vis.. (15)
Install XP pro and a Vista laptop ?? (9)
EVGA 9800 gtx help with finding a goo.. (8)
Modern Warfare For the PC (32)
Problem with speed step/turbo boost? (1)
Modern Warfare 2: Who Bought It? (61)
SIS 740 and Widescreen (8)
Baffling Problem with my CPU/MoBo's. .. (0)


All times are GMT -4. The time now is 11:42 PM.
TechIMO Copyright 2009 All Enthusiast, Inc.



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28