Php Navigation issue -
i got line of code right here:
<?php include_once('pages/component/header.php') ?> <?php include_once('pages/component/nav.php') ?> <!-- body --> <?php $action=$_get['status']; switch($action) { case 'about': include_once "pages/about.php";break; case 'portfolio': include_once "pages/portfolio.php";break; case 'contact': include_once "pages/contact.php";break; default : include_once "pages/default.php";break; } ?> <?php include_once('pages/component/footer.php') ?>
but when i'm surfing in page on wamp localhost, error saying:
notice: undefined index: status in c:\wamp\www\index.php on line 5
does body know why occurs?
it works fine when upload on ftp.
the problem not first checking if there $_get['status']
variable. example, if go url this: http://localhost/index.php
or http://localhost/
there no $_get
variable set. code have, work long have @ least ?status=
in url. must set variable if going use it.
it best first check see if there $_get variable in url. should fix problem:
<?php include_once('pages/component/header.php') ?> <?php include_once('pages/component/nav.php') ?> <!-- body --> <?php $action= (isset($_get['status'])) ? ($_get['status']) : (''); switch($action) { case 'about': include_once "pages/about.php";break; case 'portfolio': include_once "pages/portfolio.php";break; case 'contact': include_once "pages/contact.php";break; default : include_once "pages/default.php";break; } ?> <?php include_once('pages/component/footer.php') ?>
Comments
Post a Comment