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.

some help with PHP Include...

Featured Replies

g'day.

 

 

 

i'm putting the finishing touches on a website design i've been doing. but i'm having some trouble using the PHP-Include thing. I've made a site based mostly on image and its in .php format - The site has two sections that use this script, one being Tour Dates - and needs to remain there constantly - and the second being the main content section, which needs to change when the news, photos, media, video etc sections are clicked. can anyone quickly explain to me how to use this? cheers

logo.jpg

post code of scripts, works better.

I'm not sure if i understand you fully, but if i did, you don't have a problem with a particular script, and this can't post any code you have.

 

 

 

 

 

 

 

I think you are trying to avoid HTML frames, so you want one page index.php and the content changes based on the $_GET variable passed to it?

 

 

 

 

 

 

 

For example, someone goes to http://www.yoursite.co.uk and they see the main page, and the links to news photos media video are like

 

 

 

/index.php?page=news

. So you put some kind of conditional statement in the index page that is basically

 

 

 

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



include ("news.php");



}



 

 

 

 

 

 

 

And the tour dates bit you can just

 

 

 

include("tourdates.php");

wherever you need it.

 

 

 

 

 

 

 

This kind of thing is very useful when you grasp the idea of seperation of content and design. :P

 

 

 

 

 

 

 

Sorry this post is really rushed, i have to go out,ill probably edit it when i come back!

manipofsarahs1gg5.png

Instead of multiple if's for each page you add, you can use the following:

 

 

 

 

 

 

 

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



   include($_GET['page'])



}



else { include('error.html') }



 

 

 

 

 

 

 

It may not work outright (I just typed it up on the fly for this reply :P ), but it's the basic outline of how I've done most of my php include work. You would also have to edit the isfile() to fit your directory structure and so on, but it's much easier than having to edit your giant string of if's each time you add something.

switch statement > multiple if statements.

 

 

 

using the isfile() thing is hardcore problematic unless you REALLY get stuck into stopping them from navigating to wherever they want (ie:

 

 

 

 

 

 

 

page=../../.../passwords.txt

 

 

 

 

 

 

 

crudge example, but unless you know how to stop all forms of that exploit NEVER EVER use isfile() direct from $_GET or you're asking for a lot of trouble.

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

Anyhow, I believe rob's got it covered. I spoke to him last night just after he made the post and sorted it out fairly well.

Ricks right the code you posted is open to abuse. I sent Rob some code thats secure over msn the other day, not sure if he ended up using it though.

612d9da508.png

Mercifull.png

Mercifull <3 Suzi

"We don't want players to be able to buy their way to success in RuneScape. If we let players start doing this, it devalues RuneScape for others. We feel your status in real-life shouldn't affect your ability to be successful in RuneScape" Jagex 01/04/01 - 02/03/12

  • Author

Yeah, it's all sorted. i found the best way was to just treat the news, tour pages etc as html pages (but .php format) so it loads up the whole page when each menu item is clicked, but leave the php include there for tour dates. worked fine :) thanks for your help :)

logo.jpg
switch statement > multiple if statements.

 

 

 

using the isfile() thing is hardcore problematic unless you REALLY get stuck into stopping them from navigating to wherever they want (ie:

 

 

 

 

 

 

 

page=../../.../passwords.txt

 

 

 

 

 

 

 

crudge example, but unless you know how to stop all forms of that exploit NEVER EVER use isfile() direct from $_GET or you're asking for a lot of trouble.

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

Anyhow, I believe rob's got it covered. I spoke to him last night just after he made the post and sorted it out fairly well.

 

 

 

 

 

 

 

I noticed that immediately. Using if GET = whatever, include whatever.php is much better. I use that method and it's fine (and better for security).

  • Never trust anyone. You are always alone, and betrayal is inevitable.
  • Nothing is safe from the jaws of the decompiler.

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.