Jump to content

Recommended Posts

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

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

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

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.