adam291086 Posted December 20, 2007 Share Posted December 20, 2007 I want to say if $_GET is set the page = $_get otherwise page = index. At the moment it's just making page = index all the time. $page = $_GET["page"]; if (!isset ($page)); { $page = 'index'; } Link to comment https://forums.phpfreaks.com/topic/82516-solved-isset-help/ Share on other sites More sharing options...
freebsdntu Posted December 20, 2007 Share Posted December 20, 2007 $page = $_GET["page"]; if (!isset ($page)); { $page = 'index'; } Try to remove the ";" after if (!isset($page)); $page = $_GET["page"]; if (!isset ($page)) { $page = 'index'; } Link to comment https://forums.phpfreaks.com/topic/82516-solved-isset-help/#findComment-419454 Share on other sites More sharing options...
papaface Posted December 20, 2007 Share Posted December 20, 2007 $page = $_GET["page"]; switch ($page) { case "someotherpage": $page = 'someotherpage'; break; default: $page = 'index'; } or $page = trim($_GET["page"]); if ($page != "" || $page != " ") { $page = 'index'; } Link to comment https://forums.phpfreaks.com/topic/82516-solved-isset-help/#findComment-419456 Share on other sites More sharing options...
kenrbnsn Posted December 20, 2007 Share Posted December 20, 2007 Once you do <?php $page = $_GET['page']; ?> Then the variable $page is set. You should be doing something like this: <?php $page = (isset($_GET['page']))?$_GET['page']:'index'; ?> Make sure you validate the results before going to that page or including it. Ken Link to comment https://forums.phpfreaks.com/topic/82516-solved-isset-help/#findComment-419459 Share on other sites More sharing options...
adam291086 Posted December 20, 2007 Author Share Posted December 20, 2007 Thanks guys it was because of the extra ; by the isset The reason why i am checking if $_GET isset is because it's determining which page content to load from the database. If a user goes to ryedalerumble.co.uk there is nothing no indicate which content to load. Therefore set it $page to 'index'. If a user clicks on a link the url becomes ryedalerumble.co.uk/?page=index and therefore i get the page = part and search the database for it. Is this the best way? Link to comment https://forums.phpfreaks.com/topic/82516-solved-isset-help/#findComment-419467 Share on other sites More sharing options...
GuitarGod Posted December 20, 2007 Share Posted December 20, 2007 Setting the default page to 'index' in the case of no $_GET page is pretty easy. Mostly re-iterating what others have said. <?php $page = $HTTP_GET_VARS['page']; if ( !$page ) { // Your index page here include( 'index.htm' ); } else { // Other page include( $page . '.htm' ); } ?> You should somehow predefine all your pages to the $_GET page in the URL can be 'validated'. Otherwise the script will try to include ANY page the a mischievous user enters. <?php $my_pages = array( 'contact', 'about', ); $page = $HTTP_GET_VARS['page']; if ( !$page ) { // Your index page here include( 'index.htm' ); } else { // Other page if ( in_array( $page, $my_pages ) ) { // load the page include( $page . '.htm' ); } else { // page doesn't exist } } ?> Link to comment https://forums.phpfreaks.com/topic/82516-solved-isset-help/#findComment-419501 Share on other sites More sharing options...
adam291086 Posted December 20, 2007 Author Share Posted December 20, 2007 Thanks for the help guys Link to comment https://forums.phpfreaks.com/topic/82516-solved-isset-help/#findComment-419503 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.