hudsonpi Posted June 14, 2007 Share Posted June 14, 2007 I just can't figure out whats going on here. Every time you click a link, it just refreshes the home page. Any solutions? I know its right in front of my face haha. Just cant figure it out. Need expert help. thanks! http://www.srinteractive.com Quote Link to comment https://forums.phpfreaks.com/topic/55505-newbie-need-some-help/ Share on other sites More sharing options...
AndyB Posted June 14, 2007 Share Posted June 14, 2007 Can't tell what's happening from that, but it looks as though your switch statement is failing and ?page=whatever defaults to the index page. Show us the php. Quote Link to comment https://forums.phpfreaks.com/topic/55505-newbie-need-some-help/#findComment-274292 Share on other sites More sharing options...
Yesideez Posted June 14, 2007 Share Posted June 14, 2007 Care to post some code? Can't do much without it... Quote Link to comment https://forums.phpfreaks.com/topic/55505-newbie-need-some-help/#findComment-274293 Share on other sites More sharing options...
hudsonpi Posted June 14, 2007 Author Share Posted June 14, 2007 I'm sorry. should of posted some code. I don't know much about php quite yet, but I'm learning. Here is the switch: switch($page) { case "news": include_once("news.php"); break; case "careers": include_once("careers.php"); break; case "outsource": include_once("outsource.php"); break; case "investor": include_once("investor.php"); break; case "products": include_once("products.php"); break; case "about": include_once("about.php"); break; default: include_once("news.php"); } Hopefully this helps. thanks so much! Quote Link to comment https://forums.phpfreaks.com/topic/55505-newbie-need-some-help/#findComment-274320 Share on other sites More sharing options...
AndyB Posted June 14, 2007 Share Posted June 14, 2007 In the absence of code to tell us how you determine the value of $page, I'll assume that you think (or have coded as if) register_globals is ON - whereas the normal current and more secure setting is register_globals OFF. If you don't already do this, precede your switch statement by retrieving the passed value of page from the $_GET array: <?php $page = $_GET['page']; switch($page) .... etc ... ?> Quote Link to comment https://forums.phpfreaks.com/topic/55505-newbie-need-some-help/#findComment-274322 Share on other sites More sharing options...
hudsonpi Posted June 14, 2007 Author Share Posted June 14, 2007 Instead of showing you in pieces, I will include the whole source. It also includes the value of $page. Here is the entire index.php source PHP: <?php include_once("functions.php"); if(isset($_GET['page'])) { display_header($_GET['page']); } else { display_header("news"); } $html .= "<body onload=\"MM_preloadImages('images/menu_careers_red.gif','images/menu_about_red.gif','images/menu_outsource_red.gif','images/menu_contact_red.gif','images/menu_news_red.gif','images/menu_products_red.gif','images/menu_investor_red.gif', 'images/menu_careers.jpg','images/menu_about.jpg','images/menu_outsource.jpg','images/menu_contact.jpg','images/menu_news.jpg','images/menu_products.jpg','images/menu_investor.jpg', 'images/menu_spacer.jpg', 'images/menu_left.jpg')\">"; $html .= "<table width=\"100%\"><tr><td align=\"center\">"; $html .= "<div class=\"content\">"; $html .= "<div class=\"header\">"; $html .= "<img src=\"images/logo.jpg\" />"; $html .= "</div>"; // Menu $html .= "<div class=\"menu\">"; $html .= "<img src=\"images/menu_left.jpg\" />"; $html .= "<a href=\"index.php?page=news\" onMouseOver=\"imageRollover(document.getElementById('news_button'), 'images/menu_news_red.gif');\" onMouseOut=\"imageRollover(document.getElementById('news_button'), 'images/menu_news.jpg');\">"; $html .= "<img name=\"news_button\" id=\"news_button\" src=\"images/menu_news.jpg\"/></a>"; $html .= "<img src=\"images/menu_spacer.jpg\" />"; $html .= "<a href=\"index.php?page=about\" onMouseOver=\"imageRollover(document.getElementById('about_button'), 'images/menu_about_red.gif');\" onMouseOut=\"imageRollover(document.getElementById('about_button'), 'images/menu_about.jpg');\">"; $html .= "<img name=\"about_button\" id=\"about_button\" src=\"images/menu_about.jpg\"/></a>"; $html .= "<img src=\"images/menu_spacer.jpg\" />"; $html .= "<a href=\"index.php?page=outsource\" onMouseOver=\"imageRollover(document.getElementById('outsource_button'), 'images/menu_outsource_red.gif');\" onMouseOut=\"imageRollover(document.getElementById('outsource_button'), 'images/menu_outsource.jpg');\">"; $html .= "<img name=\"outsource_button\" id=\"outsource_button\" src=\"images/menu_outsource.jpg\"/></a>"; $html .= "<img src=\"images/menu_spacer.jpg\" />"; $html .= "<a href=\"index.php?page=products\" onMouseOver=\"imageRollover(document.getElementById('products_button'), 'images/menu_products_red.gif');\" onMouseOut=\"imageRollover(document.getElementById('products_button'), 'images/menu_products.jpg');\">"; $html .= "<img name=\"products_button\" id=\"products_button\" src=\"images/menu_products.jpg\"/></a>"; $html .= "<img src=\"images/menu_spacer.jpg\" />"; $html .= "<a href=\"index.php?page=investor\" onMouseOver=\"imageRollover(document.getElementById('investor_button'), 'images/menu_investor_red.gif');\" onMouseOut=\"imageRollover(document.getElementById('investor_button'), 'images/menu_investor.jpg');\">"; $html .= "<img name=\"investor_button\" id=\"investor_button\" src=\"images/menu_investor.jpg\"/></a>"; $html .= "<img src=\"images/menu_spacer.jpg\" />"; $html .= "<a href=\"index.php?page=careers\" onMouseOver=\"imageRollover(document.getElementById('careers_button'), 'images/menu_careers_red.gif');\" onMouseOut=\"imageRollover(document.getElementById('careers_button'), 'images/menu_careers.jpg');\">"; $html .= "<img name=\"careers_button\" id=\"careers_button\" src=\"images/menu_careers.jpg\"/></a>"; $html .= "</div>"; switch($page) { case "news": include_once("news.php"); break; case "careers": include_once("careers.php"); break; case "outsource": include_once("outsource.php"); break; case "investor": include_once("investor.php"); break; case "products": include_once("products.php"); break; case "about": include_once("about.php"); break; default: include_once("news.php"); } $html .= "</div>"; $html .= "<div class=\"content\">"; $html .= "<img src=\"images/copyright.jpg\" />"; $html .= "</div>"; $html .= "</td></tr></table>"; $html .= "</body>"; $html .= "</html>"; echo $html; ?> Quote Link to comment https://forums.phpfreaks.com/topic/55505-newbie-need-some-help/#findComment-274325 Share on other sites More sharing options...
mr_zhang Posted June 14, 2007 Share Posted June 14, 2007 I think it's because you haven't set the $page, it's an empty variable, thus the switch goes to DEFAULT. Add above the switch: $page=$_GET['page']; Hope this solves the problem. Regards, Quote Link to comment https://forums.phpfreaks.com/topic/55505-newbie-need-some-help/#findComment-274333 Share on other sites More sharing options...
hudsonpi Posted June 14, 2007 Author Share Posted June 14, 2007 fixed!!! Geniuses, all of you!! thanks so much. Quote Link to comment https://forums.phpfreaks.com/topic/55505-newbie-need-some-help/#findComment-274336 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.