html insert from another file/page

View previous topic View next topic Go down

avatar
grimofdoom
Member
Member
Forum Posts : 106
Member Since : 2012-03-06
View user profile

Postgrimofdoom on 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.
avatar
grimofdoom
Member
Member
Forum Posts : 106
Member Since : 2012-03-06
View user profile

Postgrimofdoom on 14/4/2012, 4:15 pm

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

PostLGforum on 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.
avatar
grimofdoom
Member
Member
Forum Posts : 106
Member Since : 2012-03-06
View user profile

Postgrimofdoom on 14/4/2012, 7:44 pm

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

Postgrimofdoom on 14/4/2012, 8:18 pm

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

PostRideem3 on 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
avatar
grimofdoom
Member
Member
Forum Posts : 106
Member Since : 2012-03-06
View user profile

Postgrimofdoom on 4/5/2012, 4:06 pm

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

PostLGforum on 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.
avatar
grimofdoom
Member
Member
Forum Posts : 106
Member Since : 2012-03-06
View user profile

Postgrimofdoom on 5/5/2012, 9:30 pm

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

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

PostMike on 6/5/2012, 5:22 am

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

Postgrimofdoom on 6/5/2012, 9:21 am

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

PostLGforum on 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.
avatar
Janzzon
Member
Member
Forum Posts : 2
Member Since : 2012-05-06
View user profile

PostJanzzon on 6/5/2012, 9:04 pm

is this possible ??
avatar
grimofdoom
Member
Member
Forum Posts : 106
Member Since : 2012-03-06
View user profile

Postgrimofdoom on 7/5/2012, 4:41 am

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

PostLGforum on 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.
avatar
Vanilla990
Administrator
Forum Posts : 114
Member Since : 2011-10-30
View user profile

PostVanilla990 on 7/5/2012, 11:17 am

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

Postgrimofdoom on 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
avatar
LGforum
Moderator
Forum Posts : 77
Member Since : 2011-11-12
View user profile

PostLGforum on 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.
avatar
grimofdoom
Member
Member
Forum Posts : 106
Member Since : 2012-03-06
View user profile

Postgrimofdoom on 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>
avatar
LGforum
Moderator
Forum Posts : 77
Member Since : 2011-11-12
View user profile

PostLGforum on 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'); ?>
avatar
grimofdoom
Member
Member
Forum Posts : 106
Member Since : 2012-03-06
View user profile

Postgrimofdoom on 10/5/2012, 5:01 am

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

PostLGforum on 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