html insert from another file/page
Page 1 of 1 • Share
- grimofdoomMember
- Forum Posts : 106
Member Since : 2012-03-06
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.
- grimofdoomMember
- Forum Posts : 106
Member Since : 2012-03-06
nvm, I have solved this through IFRAME .though if someone knows something more simple,please tell.
- LGforumModerator
- Forum Posts : 77
Member Since : 2011-11-12
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.
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.
- grimofdoomMember
- Forum Posts : 106
Member Since : 2012-03-06
I was able to make it look natural with iframe (here).though ill look into php Include.
- grimofdoomMember
- Forum Posts : 106
Member Since : 2012-03-06
i tried and it didnt seam to work.
- grimofdoomMember
- Forum Posts : 106
Member Since : 2012-03-06
I am not a php master, but ive used php pieces for like time/date in .html files.
- LGforumModerator
- Forum Posts : 77
Member Since : 2011-11-12
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.
Changing '/header.html' with the file path to whatever you wish to include.
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.
- grimofdoomMember
- Forum Posts : 106
Member Since : 2012-03-06
im talking about regular html pages(web host)
- LGforumModerator
- Forum Posts : 77
Member Since : 2011-11-12
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.
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.
- grimofdoomMember
- Forum Posts : 106
Member Since : 2012-03-06
im completely comfused you guys atr saying this stuff but not telling the actual code usable.
- LGforumModerator
- Forum Posts : 77
Member Since : 2011-11-12
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.
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.
- JanzzonMember
- Forum Posts : 2
Member Since : 2012-05-06
is this possible ??
- grimofdoomMember
- Forum Posts : 106
Member Since : 2012-03-06
this is what comes out when i try that: http://simage.net76.net/home/test.html
- LGforumModerator
- Forum Posts : 77
Member Since : 2011-11-12
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.
And double check that your file path is correct and that the file exists.
- Vanilla990Administrator
- Forum Posts : 114
Member Since : 2011-10-30
why is the file called "test.html", shouldn't it be called "test.php"?
- grimofdoomMember
- Forum Posts : 106
Member Since : 2012-03-06
i changed both of the pages as .ph and it comes out to http://simage.net76.net/home/test.php
- LGforumModerator
- Forum Posts : 77
Member Since : 2011-11-12
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.
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.
- grimofdoomMember
- Forum Posts : 106
Member Since : 2012-03-06
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
test2.html
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>
- LGforumModerator
- Forum Posts : 77
Member Since : 2011-11-12
Since the file is in the same directory, you'd just need this as the PHP:
- Code:
<?php include('test2.html'); ?>
- grimofdoomMember
- Forum Posts : 106
Member Since : 2012-03-06
It worked now,thanks!
- LGforumModerator
- Forum Posts : 77
Member Since : 2011-11-12
Glad to hear.
I recommend you look into how file paths work so your more comfortable using them.
I recommend you look into how file paths work so your more comfortable using them.
- Sponsored content
Similar topics
Create an account or log in to leave a reply
You need to be a member in order to leave a reply.
Page 1 of 1
Permissions in this forum:
You cannot reply to topics in this forum