Skip to content
View in the app

A better way to browse. Learn more.

Tip.It Forum

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Detecting the existance of URL arguments? (PHP)

Featured Replies

if ($_GET['page'] == NULL) {

  		include('main.php');

} else {

	include($_GET['page']);

}

 

 

 

I'm trying to achieve the same effect as used by tip.it :?

 

 

 

This works when I have ?page=somepage.php, but throws an error when it isn't there. The above was an attempt to get around that, so that I can visit my homepage by sitename/ rather than sitename/?page=main.php

Or try

 

 

 

if (!isset($_GET['page'])) {

  		include('main.php');

} else {

	include($_GET['page']);

}

Or try

 

 

 

if (!isset($_GET['page'])) {

  		include('main.php');

} else {

	include($_GET['page']);

}

 

 

 

Could also probably do it the other way around :

 

 

 

if ($_GET['page']) {

               include($_GET['page']);

} else {

	include('main.php');

}

 

 

 

Or :

 

 

 

if (is_null($_GET['page'])) {

  		include('main.php');

} else {

	include($_GET['page']);

}

Try this instead :

 

 

 

if ($_GET['page'] === NULL) {

        include('main.php');

  } else {

     include($_GET['page']);

  } 

 

Personally I would use

 

if(!empty($_GET['page']))

  {

  require($_GET['page']);

  }

else

  {

  require('main.php');

  }

 

empty() works better then isset() in this case and personally I always use require() instead of include().

[hide=Drops]

  • Dragon Axe x11
    Berserker Ring x9
    Warrior Ring x8
    Seercull
    Dragon Med
    Dragon Boots x4 - all less then 30 kc
    Godsword Shard (bandos)
    Granite Maul x 3

Solo only - doesn't include barrows[/hide][hide=Stats]

joe_da_studd.png[/hide]

 

Could also probably do it the other way around :

 

 

 

if ($_GET['page']) {

               include($_GET['page']);

} else {

	include('main.php');

}

 

 

The above is my preferred method. You must include some kind of is_file() check to a specific directory with the pages in it or limit the include to a certain set of files if you do use any of the posted snippets though. If you don't, you're just asking for someone to come along and use the get method to find ways into your sensitive or OS related files.

 

Could also probably do it the other way around :

 

 

 

if ($_GET['page']) {

               include($_GET['page']);

} else {

	include('main.php');

}

 

 

The above is my preferred method. You must include some kind of is_file() check to a specific directory with the pages in it or limit the include to a certain set of files if you do use any of the posted snippets though. If you don't, you're just asking for someone to come along and use the get method to find ways into your sensitive or OS related files.

 

 

 

if ($_GET['page'] && preg_match('/.php/',$_GET['page'])) {

               include($_GET['page']);

} else {

	include('main.php');

}

 

 

 

Eh?

 

(Regular expression matching isn't my favorite thing to do, I can never remember all of the patterns and stuff)

This is more what I was shooting for. The code I use is a bit different because I use mod_rewrite, but it's the general idea.

 

 

 

  // If no page, use the default

 if (!$_GET['page'])

 {

   include('pages/default.html');

 } 

 // Include page if we know its a web page we want to include

 elseif (is_file("pages/".$_GET['page'].".html"))

 {

   include("pages/".$_GET['page'].".html");

 } 

 // Choke and tell them it doesn't exist

 else { echo 'Page not found'; } 

 

 

 

This limits the ?page= setup to just files found in your /pages/ directory, which stops any browsing of other files you may not want being spit out by include() or require(). If it isn't in that folder, it doesn't get used.

  • Author

Thanks for all the solutions techies :)

Create an account or sign in to comment

Important Information

By using this site, you agree to our Terms of Use.

Account

Navigation

Search

Search

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.