View Full Version : PHP Include, Then Change File By Link

08-11-2008, 07:06 PM
I know this is possible, but i can't find the tiny bit of coding.

If i have 'Page1.html' Included Into My Webpage Using PHP Include

How Do I make a link, so i can put Page2.Html there instead just like and iframe

I thinks its PHP.

08-11-2008, 07:18 PM
It'd have to reload the page or use ajax. Heres for it to reload the page:

switch($_GET['changePage']) { //switch is just like a bunch of if()s
default: //default case
case 'default': //default case
include('page1.html'); //include page.html
break; //break, witch means stop
case 'page2': // page2, if changePage has the value of page2
include('page2.html'); //include page2.html
break; //stop it
} //end the switch

The above is assuming you have the basic knowledge of switch()
Now to change it:

<a href="page.php?changePage=page2">Page2</a>

Now, your wondering why I just don't do this:


Its unsecure, for example if that page is protected by htaccess files, it won't protect the include.
If you don't understand the first script I gave you, please lemme know.

08-11-2008, 08:16 PM
That last one was it, i remember when i saw it.

but after reading that, i'll use the first script.

But my site is an online radio so.

So the page cant refresh or my radi owill stop.

is there a way of doing it silently

08-11-2008, 08:30 PM
Ajax, I suggest taking a look at this:
There are so many ways to do it without PHP, but then if the browser doesn't support javascript, the code will fail.

08-11-2008, 08:31 PM
Ok i will have a look at that.

Its not Majorly important, it actually to change the background color.

i cnt do it via style switcher as i use that to change skin color.

So Thanks.

08-11-2008, 08:39 PM
So then why not use javascript:

<a href="javascript:void(0);" onClick="document.body.style.background='lightgreen';">Light Green</a>

08-11-2008, 08:45 PM
Becuase i didnt know you could.

Thanks alot!

Im gonna use the ajax script for content now.


08-11-2008, 08:50 PM
Lol, well there you go, glad to help.

08-11-2008, 08:51 PM

And can i use them links to set background images?

08-11-2008, 08:54 PM
Indeed you can:

<a href="javascript:void(0);" onClick="document.body.style.background='url(http://www.dynamicdrive.com/forums/designfiles/logo.gif)';">BG</a>

You can use buttons too:

<button onClick="document.body.style.background='url(http://www.dynamicdrive.com/forums/designfiles/logo.gif)';">BG</button>

I hope this helps,

08-11-2008, 08:58 PM

You Are Super!, Thank You So Much.

BTW, One last question, do you have any idea why my iFrame resizing script won't work?

I have the number 2, which bases the height of the iframe on the page loaded into it. I've tried everything.

i've even just directly copied everything over from DD to my site.

Still nothing.

it works fine on some, but on my hosts, whos on Mac, using Safari, t loads the first one in just fine but hwne u click other links it dosent move. ( this is the one that is meant to do other links too )

Or do you know any other scripts that do the same.


08-11-2008, 08:59 PM
Can I see a link to the page and the code? It will help when I'm trying to solve the problem. :)

08-11-2008, 09:17 PM
Well erm i kinda destroyed the pages

let me re-create them and i'll give you the link.

08-11-2008, 09:29 PM
here includes the script and iframe code directly copied from DD

1 outside frame link ( copied from DD )

1 inside frame link ( standard )

And yes, Im afraid its a Habbo Fansute -dunn dunn dunnn-

But ive been trying to get this to work for about 5 months !!!!


08-11-2008, 10:10 PM
Can you take a screen shot, the resize works perfectly for me.

08-12-2008, 03:48 PM
It works great for me too.

It's my friend who is on Safari running Mac OS

Who says that when he clicks a link it dosent resize, but it will resize to the first page when he loads the test page.