Forum Moderators: mack
I have a .htm file called 'header.htm' which contains my navigation and logo
The other page which im inserting my 'header' using the #include is called 'index.asp'
The problem is when i use Dreamweaver, the included file 'header.htm' appears correct in the index.asp file, but when i try and add more contect below this it wont let me.
here is the code for index.asp
<%@LANGUAGE="JAVASCRIPT" CODEPAGE="1252"%>
<html>
<head>
<title>Untitled Document</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<!--#include virtual="header.htm"-->
</head>
<body>
</body>
</html>
and code for header.htm
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title></title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>
<body background="images/background.jpg">
<table width="100%" border="0" align="center" cellpadding="0" cellspacing="0" background="images/top-back.jpg">
<tr>
<td width="30%" height="115" rowspan="3"><div align="center"><img src="images/butterfly.jpg" width="173" height="115" align="top"></div></td>
<td width="26%" rowspan="3"><img src="images/adas.jpg" width="176" height="115"></td>
<td width="44%" valign="top"><div align="center"><img src="images/alcohol.jpg" width="302" height="30" align="top"></div></td>
</tr>
<tr>
<td valign="bottom">service contacts us</td>
</tr>
</table>
<p> </p></body>
</html>
What am i doing wrong, as i cannot put anything in the body of the index.asp file
thanks
<edit>
I just re-read your message and it's obvious that you do have <head> etc tags in there - try removing them from the include file.
</edit>
Also, when working with includes you need to remember that you can do it two ways:
<!--#include file="header.htm"-->
This expects your header.htm to be in the same folder as all pages calling it.
On the other hand:
<!--#include virtual="/header.htm"-->
Is what I prefer as it allows me to always reference it from the root.
<%@LANGUAGE="JAVASCRIPT" CODEPAGE="1252"%>
<html>
<head>
<title>Untitled Document</title>
<!--/////////// Start Header \\\\\\\\\\\\\\-->
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title></title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>
<body background="images/background.jpg">
<table width="100%" border="0" align="center" cellpadding="0" cellspacing="0" background="images/top-back.jpg">
<tr>
<td width="30%" height="115" rowspan="3"><div align="center"><img src="images/butterfly.jpg" width="173" height="115" align="top"></div></td>
<td width="26%" rowspan="3"><img src="images/adas.jpg" width="176" height="115"></td>
<td width="44%" valign="top"><div align="center"><img src="images/alcohol.jpg" width="302" height="30" align="top"></div></td>
</tr>
<tr>
<td valign="bottom">service contacts us</td>
</tr>
</table>
<p> </p></body>
</html>
<!--/////////// End Header \\\\\\\\\\\\\\-->
</head>
<body>
</body>
</html>
You are closing your document in the header. I would try something like:
Header include(header.inc):
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>
<body background="images/background.jpg">
<table width="100%" border="0" align="center" cellpadding="0" cellspacing="0" background="images/top-back.jpg">
<tr>
<td width="30%" height="115" rowspan="3"><div align="center"><img src="images/butterfly.jpg" width="173" height="115" align="top"></div></td>
<td width="26%" rowspan="3"><img src="images/adas.jpg" width="176" height="115"></td>
<td width="44%" valign="top"><div align="center"><img src="images/alcohol.jpg" width="302" height="30" align="top"></div></td>
</tr>
<tr>
<td valign="bottom">service contacts us</td>
</tr>
</table>
<p> </p>
Asp pages(default.asp):
<%@LANGUAGE="JAVASCRIPT" CODEPAGE="1252"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>Untitled Document</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<!--#include virtual="header.inc"-->
<!--///////////// Start Content \\\\\\\\\\\\\\\\\\\-->
<!--///////////// End Content \\\\\\\\\\\\\\\\\\\-->
<!--#include virtual="footer.inc"-->
Footer include(footer.inc):
<!--//// Bottom navigation, copyright, and other global bottom info \\\\-->
</body>
</html>
<added>
Also, when working with includes you need to remember that you can do it two ways:<!--#include file="header.htm"-->
This expects your header.htm to be in the same folder as all pages calling it.
On the other hand:
<!--#include virtual="/header.htm"-->
Is what I prefer as it allows me to always reference it from the root.
This is also important. If you have folders with pages then it has to be done without breaking the page.
</added>
If you were to have asp code in your include file which contains database connection scripts etc and name it as .inc, there is the possibility that somebody will find this file and be able to read your database connection passwords as plain text.
If the include file was names with a .asp extension, nothing would output in this scenario thus securing your database conntection or whatever is in the script.
I have seen many instances of search engines indexing .inc files that include sensitive information when the .inc file does not execute correctly and is able to be indexed.
My includes never work unless I have that extra space before the --> like this:
<!--#include file="header.htm" -->
I also have to add the filetype in .htaccess so it'll work with .htm in addition to .shtm but that's Apache. Try adding the space and see if that helps. It looks wrong but it's supposed to be there.
Don't assume your global.asa file is secure either. If anything its more vulnerable then using a .asp file for connecting to a db. There are ways to read the global.asa without using a browser to see a plain text version of it.
check this book Hacking Web Applications Exposed for some more info.