Chatbox

You are not connected. Please login or register

View previous topic View next topic Go down  Message [Page 1 of 1]

1 html insert from another file/page on 14/4/2012, 2:38 pm

grimofdoom

avatar

Member
How can i make an html page div go into another page(s) so i only have to change that one page instead of every single other.

View user profile

grimofdoom

avatar

Member
nvm, I have solved this through IFRAME .though if someone knows something more simple,please tell.

View user profile

LGforum

avatar

Moderator
Stuff like this sort of sounds like the usage for PHP Includes.

I presume you mean stuff like, in every page you have the same header and navbar. Its good to make one file named 'header' and just include that in all other files. So you only need to edit the header file to update your header...

Look into PHP Includes. IFRAMES are bad.

View user profile

grimofdoom

avatar

Member
I was able to make it look natural with iframe (here).though ill look into php Include.

View user profile

grimofdoom

avatar

Member
i tried and it didnt seam to work.

View user profile

Rideem3

avatar

Premium Member
Are you using PHP on an HTML page, on Forumotion? Lol Razz
1. HTML pages don't support PHP, unless specified in a .htaccess file via Apache
2. Forumotion doesn't allow your own PHP anywhere. Wink

View user profile http://malware-site.www/

grimofdoom

avatar

Member
I am not a php master, but ive used php pieces for like time/date in .html files.

View user profile

LGforum

avatar

Moderator
He's not talking about Forumotion a I believe.

Using a PHP include is simple. The file in which you are using the include in must be a PHP file of course.

Code:

<?php  include('/header.html'); ?>

Changing '/header.html' with the file path to whatever you wish to include.

View user profile

grimofdoom

avatar

Member
im talking about regular html pages(web host)

View user profile

LGforum

avatar

Moderator
Well you can't use PHP Includes in a HTML file. And an Iframe is a terrible terrible way to do so.

I'd recommend changing your HTML file to a PHP file. To do that all you need to do is change the file extension to '.php'
Then you can add the include function like shown above make use of includes.

View user profile

Drogba921

avatar

Administrator
Coldfusion using Cfinclude FTW!

View user profile http://www.codinghelp.org

grimofdoom

avatar

Member
im completely comfused you guys atr saying this stuff but not telling the actual code usable.

View user profile

LGforum

avatar

Moderator
I gave you the code here: http://www.codinghelp.org/t249-html-insert-from-another-file-page#1468

Thats all there is to including a file in another. All you have to do is change '/header' with the file path to whatever your trying to include.

View user profile

Janzzon

avatar

Member
is this possible ??

View user profile

grimofdoom

avatar

Member
this is what comes out when i try that: http://simage.net76.net/home/test.html

View user profile

LGforum

avatar

Moderator
Well you can show me the exact PHP you used if you'd like.

And double check that your file path is correct and that the file exists.

View user profile

Vanilla990

avatar

Administrator
why is the file called "test.html", shouldn't it be called "test.php"?

View user profile

grimofdoom

avatar

Member
i changed both of the pages as .ph and it comes out to http://simage.net76.net/home/test.php

View user profile

LGforum

avatar

Moderator
PHP can also include HTML files. So the file your actually including does not need to be a PHP file. But the file making the include does have to be.

Link me to both the files. The one your trying to use the include in and the on your trying to include.

And also show me your PHP code you using.

View user profile

grimofdoom

avatar

Member
urkl of file to put in:http://simage.net76.net/home/test.php
url to file to put into:htt[://simage.net76.net/home/test2.html

test.php
Code:
<?php  include('http://simage.net76.net/home/test2.html'); ?>

test2.html
Code:
<div>it worked</div>

View user profile

LGforum

avatar

Moderator
Since the file is in the same directory, you'd just need this as the PHP:

Code:

<?php  include('test2.html'); ?>

View user profile

grimofdoom

avatar

Member
It worked now,thanks!

View user profile

23 Re: html insert from another file/page on 10/5/2012, 10:05 am

LGforum

avatar

Moderator
Glad to hear.
I recommend you look into how file paths work so your more comfortable using them. Wink

View user profile

Sponsored content


View previous topic View next topic Back to top  Message [Page 1 of 1]

Permissions in this forum:
You cannot reply to topics in this forum