html insert from another file/page

View previous topic View next topic Go down

grimofdoom
grimofdoom
Member
Member
Forum Posts : 106
Member Since : 2012-03-06

Postgrimofdoom 14/4/2012, 12:38 pm

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.
grimofdoom
grimofdoom
Member
Member
Forum Posts : 106
Member Since : 2012-03-06

Postgrimofdoom 14/4/2012, 4:15 pm

nvm, I have solved this through IFRAME .though if someone knows something more simple,please tell.
LGforum
LGforum
Moderator
Forum Posts : 77
Member Since : 2011-11-12

PostLGforum 14/4/2012, 5:00 pm

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.
grimofdoom
grimofdoom
Member
Member
Forum Posts : 106
Member Since : 2012-03-06

Postgrimofdoom 14/4/2012, 7:44 pm

I was able to make it look natural with iframe (here).though ill look into php Include.
grimofdoom
grimofdoom
Member
Member
Forum Posts : 106
Member Since : 2012-03-06

Postgrimofdoom 14/4/2012, 8:18 pm

i tried and it didnt seam to work.
Rideem3
Rideem3
Premium Member
Premium Member
Forum Posts : 8
Member Since : 2011-12-28
http://malware-site.www/

PostRideem3 3/5/2012, 4:39 pm

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
grimofdoom
grimofdoom
Member
Member
Forum Posts : 106
Member Since : 2012-03-06

Postgrimofdoom 4/5/2012, 4:06 pm

I am not a php master, but ive used php pieces for like time/date in .html files.
LGforum
LGforum
Moderator
Forum Posts : 77
Member Since : 2011-11-12

PostLGforum 5/5/2012, 4:23 pm

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.
grimofdoom
grimofdoom
Member
Member
Forum Posts : 106
Member Since : 2012-03-06

Postgrimofdoom 5/5/2012, 9:30 pm

im talking about regular html pages(web host)
LGforum
LGforum
Moderator
Forum Posts : 77
Member Since : 2011-11-12

PostLGforum 5/5/2012, 9:52 pm

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.
Mike
Mike
Administrator
Forum Posts : 446
Member Since : 2011-10-28
http://www.codinghelp.org

PostMike 6/5/2012, 5:22 am

Coldfusion using Cfinclude FTW!
grimofdoom
grimofdoom
Member
Member
Forum Posts : 106
Member Since : 2012-03-06

Postgrimofdoom 6/5/2012, 9:21 am

im completely comfused you guys atr saying this stuff but not telling the actual code usable.
LGforum
LGforum
Moderator
Forum Posts : 77
Member Since : 2011-11-12

PostLGforum 6/5/2012, 6:49 pm

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.
Janzzon
Janzzon
Member
Member
Forum Posts : 2
Member Since : 2012-05-06

PostJanzzon 6/5/2012, 9:04 pm

is this possible ??
grimofdoom
grimofdoom
Member
Member
Forum Posts : 106
Member Since : 2012-03-06

Postgrimofdoom 7/5/2012, 4:41 am

this is what comes out when i try that: http://simage.net76.net/home/test.html
LGforum
LGforum
Moderator
Forum Posts : 77
Member Since : 2011-11-12

PostLGforum 7/5/2012, 11:05 am

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.
Vanilla990
Vanilla990
Administrator
Forum Posts : 114
Member Since : 2011-10-30

PostVanilla990 7/5/2012, 11:17 am

why is the file called "test.html", shouldn't it be called "test.php"?
grimofdoom
grimofdoom
Member
Member
Forum Posts : 106
Member Since : 2012-03-06

Postgrimofdoom 7/5/2012, 6:47 pm

i changed both of the pages as .ph and it comes out to http://simage.net76.net/home/test.php
LGforum
LGforum
Moderator
Forum Posts : 77
Member Since : 2011-11-12

PostLGforum 8/5/2012, 8:52 am

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.
grimofdoom
grimofdoom
Member
Member
Forum Posts : 106
Member Since : 2012-03-06

Postgrimofdoom 8/5/2012, 1:46 pm

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>
LGforum
LGforum
Moderator
Forum Posts : 77
Member Since : 2011-11-12

PostLGforum 9/5/2012, 8:46 pm

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

Code:

<?php  include('test2.html'); ?>
grimofdoom
grimofdoom
Member
Member
Forum Posts : 106
Member Since : 2012-03-06

Postgrimofdoom 10/5/2012, 5:01 am

It worked now,thanks!
LGforum
LGforum
Moderator
Forum Posts : 77
Member Since : 2011-11-12

PostLGforum 10/5/2012, 8:05 am

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

PostSponsored content

View previous topic View next topic Back to top

Create an account or log in to leave a reply

You need to be a member in order to leave a reply.

Create an account

Join our community by creating a new account. It's easy!


Create a new account

Log in

Already have an account? No problem, log in here.


Log in

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