ShibSta Posted March 25, 2006 Share Posted March 25, 2006 I have the following,[code]<?php $p = $_GET['p'];?><html><head><title>Index</title><meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"></head><body bgcolor="#A4AFB4" leftmargin="0" topmargin="0" marginwidth="0" marginheight="0"><table width="580" height="521" border="0" align="center" cellpadding="0" cellspacing="0" bgcolor="#A4AFB4"> <tr> <td width="580" height="249"><table width="580" height="268" border="0" cellpadding="0" cellspacing="0"> <tr> <td width="54" rowspan="2"><img src="images/head_tl.gif" width="54" height="82" alt=""></td> <td width="257" rowspan="2"><img src="images/head_logo.gif" width="257" height="82" alt=""></td> <td width="74" rowspan="2"><img src="images/head_logor.gif" width="74" height="82" alt=""></td> <td width="195" height="21"><img src="images/head_links.gif" alt="" width="195" height="21" border="0" usemap="#Map"></td> </tr> <tr> <td height="61"><img src="images/head_linksb.gif" width="195" height="61" alt=""></td> </tr> <tr> <td height="167"><img src="images/head_bl.gif" width="54" height="167" alt=""></td> <td><img src="images/head_logob.gif" width="257" height="167" alt=""></td> <td><img src="images/head_logobr.gif" width="74" height="167" alt=""></td> <td><img src="images/head_comps.gif" width="195" height="167" alt=""></td> </tr> <tr> <td height="19" colspan="4"> <table width="580" height="46" border="0" cellpadding="0" cellspacing="0"> <tr> <td width="16" height="46"><img src="images/nav_bl.gif" width="16" height="46" alt=""></td> <td width="100"><a href="index2.php?p=about"><img src="images/nav_about.gif" alt="" width="100" height="46" border="0"></a></td> <td width="99"><a href="index2.php?p=hosting"><img src="images/nav_hosting.gif" alt="" width="99" height="46" border="0"></a></td> <td width="99"><a href="index2.php?p=domains"><img src="images/nav_domains.gif" alt="" width="99" height="46" border="0"></a></td> <td width="99"><a href="index2.php?p=support"><img src="images/nav_support.gif" alt="" width="99" height="46" border="0"></a></td> <td width="99"><a href="index2.php?p=contact"><img src="images/nav_contacts.gif" alt="" width="99" height="46" border="0"></a></td> <td width="55"><img src="images/nav_r.gif" width="55" height="46" alt=""></td> <td width="13"><img src="images/nav_br.gif" width="13" height="46" alt=""></td> </tr> </table></td> </tr> </table></td> </tr> <tr> <td height="169"><table width="580" height="169" border="0" cellpadding="0" cellspacing="0"> <tr> <td width="16" height="169" background="images/main_l.gif"><img src="images/main_l.gif" width="16" height="1"></td> <td width="551" valign="top"> <table width="100%" border="0" align="center" cellpadding="0" cellspacing="0"> <tr> <td width="224" align="left" valign="top"><table width="551" height="169" border="0" cellpadding="0" cellspacing="0"> <tr> <td width="42" rowspan="2"><img src="images/news_tl.gif" width="42" height="44" alt=""></td> <td height="13" colspan="4"><img src="images/news_t.gif" width="466" height="13" alt=""></td> <td width="43" rowspan="2"><img src="images/about_tr.gif" width="43" height="44" alt=""></td> </tr> <tr> <td width="162" height="31"><img src="images/news_title.gif" width="162" height="31" alt=""></td> <td colspan="2"><img src="images/mid_t.gif" width="41" height="31" alt=""></td> <td width="263"><?php if ($p) { $p = $p; } else { $p = about; }?> <img src="images/<?php echo "$p"; ?>_title.gif" width="263" height="31" alt=""> </td> </tr> <tr> <td height="80" background="images/news_bl.gif"><img src="images/news_bl.gif" width="42" height="1" alt=""></td> <td valign="top" bgcolor="#F4F4F4"> </td> <td colspan="2" background="images/mid.gif"><img src="images/mid.gif" width="41" height="1" alt=""></td> <td valign="top" bgcolor="#F4F4F4"><?php if ($p) { $p = $p . '.php'; include("pages/$p"); } else { include('pages/about.php'); }?></td> <td background="images/about_br.gif"><img src="images/about_br.gif" width="43" height="1" alt=""></td> </tr> <tr> <td height="21"><img src="images/news_cl.gif" width="42" height="21" alt=""></td> <td bgcolor="#F4F4F4"><img src="images/spacer.gif" width="162" height="21" alt=""></td> <td width="20"><img src="images/mid_bl.gif" width="20" height="21" alt=""></td> <td width="21"><img src="images/mid_br.gif" width="21" height="21" alt=""></td> <td bgcolor="#F4F4F4"><img src="images/spacer.gif" width="263" height="21" alt=""></td> <td><img src="images/about_cr.gif" width="43" height="21" alt=""></td> </tr> <tr> <td height="24"><img src="images/main_cl.gif" width="42" height="24" alt=""></td> <td colspan="4"><img src="images/main_b.gif" width="466" height="24" alt=""></td> <td><img src="images/main_cr.gif" width="43" height="24" alt=""></td> </tr> </table></td> </tr> </table> </td> <td width="13" background="images/main_r.gif"><img src="images/main_r.gif" width="13" height="1"></td> </tr> </table></td> </tr> <tr> <td height="57"><table width="578" height="56" border="0" cellpadding="0" cellspacing="0"> <tr> <td height="15" colspan="2"><img src="images/foot_gradient.gif" width="567" height="15" alt=""></td> <td width="13" rowspan="2"><img src="images/home2_50.gif" width="13" height="56"></td> </tr> <tr> <td width="43" height="41"><img src="images/foot_bl.gif" width="43" height="41" alt=""></td> <td width="524"><img src="images/foot_text.gif" width="524" height="41" alt=""></td> </tr> </table></td> </tr></table><map name="Map"><area shape="rect" coords="3,6,33,16" href="index2.php?p=about"><area shape="rect" coords="49,6,98,16" href="index2.php?p=services"><area shape="rect" coords="115,6,164,16" href="index2.php?p=support"></map></body></html>[/code]As you see I have a script to pull the proper image aswell as the proper content.I am wanting to know how I can make it display a page not found image and content page if the $p is not an existing file.I know it would have to do with the file exist, however I would like some assistance.I do not know how to put it together and I'm a visual learner, could someone please post it for me?Thanks Quote Link to comment Share on other sites More sharing options...
litebearer Posted March 26, 2006 Share Posted March 26, 2006 Not sure if I understand correctly, but....[code]<?PHP$substitute_file_name = "There is no file";$substitue_image_name = "There is no image";$filename = '/path/to/whatever.txt';$imagename = '/path/to/whateverimage.jpg';if (!file_exists($filename)) { $filename = $substitute_file_name; $imagename = substitute_image_name;}echo $filename . "<br>";echo $imagename;?>[/code]does that help?Lite... Quote Link to comment Share on other sites More sharing options...
phileplanet Posted March 26, 2006 Share Posted March 26, 2006 [quote name='ShibSta' date='Mar 25 2006, 06:02 PM' post='358394']I have the following,[code]<?php $p = $_GET['p'];?><html>.......[/quote]Okay. First of all, shorten your code! We don't need to see all the html. Secondly, with this part:[code]<?php if ($p) { $p = $p . '.php'; include("pages/$p"); } else { include('pages/about.php'); }?>[/code]you can't just have a variable there. You have to have $p = "something" or whatever. Quote Link to comment Share on other sites More sharing options...
ShibSta Posted March 26, 2006 Author Share Posted March 26, 2006 Got it working using the following:[code]<?php $p = $_GET['p'];if ($p) { $pg = $p;} else { $pg = about;}$nfpage = 'pages/notfound.php';$nfimg = 'images/imgs_notfound_title.gif';$img = "images/imgs_{$pg}_title.gif";$page = "pages/$pg.php";if (!file_exists($page)) { $page = $nfpage; $img = $nfimg;}?>[/code] Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.