papillonstudios Posted May 4, 2010 Share Posted May 4, 2010 OK im getting an undefined index in this code Notice: Undefined index: page in *FilePath*/index.php on line 5 <?php include('functions.php'); $nav = $_GET['page']; secure($nav); $siteurl = 'http://localhost:8888/healthycpus'; ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /> <title>Home Page</title> <link rel="stylesheet" type="text/css" href="healthy.css" /> <script type="text/javascript"> // Copyright 2006-2007 javascript-array.com var timeout = 250; var closetimer = 0; var ddmenuitem = 0; // open hidden layer function mopen(id) { // cancel close timer mcancelclosetime(); // close old layer if(ddmenuitem) ddmenuitem.style.visibility = 'hidden'; // get new layer and show it ddmenuitem = document.getElementById(id); ddmenuitem.style.visibility = 'visible'; } // close showed layer function mclose() { if(ddmenuitem) ddmenuitem.style.visibility = 'hidden'; } // go close timer function mclosetime() { closetimer = window.setTimeout(mclose, timeout); } // cancel close timer function mcancelclosetime() { if(closetimer) { window.clearTimeout(closetimer); closetimer = null; } } // close layer when click-out document.onclick = mclose; </script> </head> <body> <div class="wrapper"> <div class="header"> <img src="images/header.png" /> </div> <div class="navbar"> <ul id="sddm"> <li><a href="<?=$siteurl?>">Home</a></li> <li><a href="#" onmouseover="mopen('m1')" onmouseout="mclosetime()">Products</a> <div id="m1" onmouseover="mcancelclosetime()" onmouseout="mclosetime()"> <a href="#">Monitors</a> <a href="#">Computers</a> <a href="#">Notebooks</a> <a href="#">Netbooks</a> </div> </li> <li><a href="#" onmouseover="mopen('m2')" onmouseout="mclosetime()">Services</a> <div id="m2" onmouseover="mcancelclosetime()" onmouseout="mclosetime()"> <a href="#">Service 1</a> <a href="#">Service 2</a> <a href="#">Service 3</a> <a href="#">Service 4</a> </div> </li> <li><a href="#">Stores</a></li> <li><a href="#">Help</a></li> <li><a href="#">Contact</a></li> </ul> <div style="clear:both"></div> </div> <div class="content"> <?php //Use a switch statement to go through the URLS. switch ($nav) { case "services": include ('services.php'); break; case "aboutme": include ('about.php'); break; case "portfolio": include ('sites.php'); break; case "contact": include ('contact.php'); break; case "services": include ('services.php'); break; default: include ('default.php'); break; } ?> </div> </div> </body> </html> so what am i doing wrong Link to comment https://forums.phpfreaks.com/topic/200621-undefined-index/ Share on other sites More sharing options...
Alex Posted May 4, 2010 Share Posted May 4, 2010 $_GET['page'] isn't always going to be defined. You should be doing something like: $nav = isset($_GET['page']) ? $_GET['page'] : null; Link to comment https://forums.phpfreaks.com/topic/200621-undefined-index/#findComment-1052797 Share on other sites More sharing options...
papillonstudios Posted May 4, 2010 Author Share Posted May 4, 2010 ok thanx man problem solved Link to comment https://forums.phpfreaks.com/topic/200621-undefined-index/#findComment-1052798 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.