Tom's Guide | Tom's Hardware | Tom's Games
![]() |
![]() |
![]() |
I am a newb. I have a site written using PHP and CSS. I was to add some text and images into a header that will show up on all pages. Can this be done by altering the CSS? If so, where can I find some examples.

So, you want to add a header to all pages. This should be done with PHP. You simply add:
<?php include("header.php"); ?>
And change header.php to read whatever page has the header you want included on every page.

thats pretty cool. so now when i wanna do something like that, i wont need any more frames. stupid frames
FBI_Agent

@James
I have php include to pull in a search engine script on my site's search page, but I use SSI to pull in common header and footer across the whole site. I don't use .shtml, I use .html with Xbithack on instead, so it only parses the pages set for Owner execute.
In your view, which is better for the common elements, in terms of server burden, and which is more reliable overall? Load speed is fast for the visitor on my site anyway, so this comes down to optimising backend performance and miniminsing drain. Or maybe because the header and footer cache immediately, it really doesn't make much difference?

safeTsurfa,
I don't really think it makes much of a difference. For your search page, all the server has to do is perform a total of three file operations: one for the actual page, one for the search script that is included and another for the SSI header you have across the site.
Unless your server is overloaded with traffic and slowing down to turtle pace, I wouldn't worry about it. But, hey, that Xbithack thing is cool. I've never seen that before... ^_^
James

@ safeTsurfa
Since your html-files are parsed by SSI _AND_ the php-parser, I would recommend you to place the headers in the php-method also. That way the file is only parsed once, and can be sent to the client quicker.

@Khalid
Thanks, it's only the one page which parses with php as it performs a search. I will look at using php for the headers though, may try a test page with it.
@ James
Yep, I picked up the Xbithack trick a while back. I used to set a command in HTACCESS to parse all .html files, but this is better, as it only does it to those which need it and have the CHMOD set.

OK, I created a header file and and place the PHP statement on the first line of the CSS file, but it didn't work, I just lost my backgroud color. Next I tried to put the PHP statement in the page I was trying to load. It works but I loose some of my formating. Any suggestions would be appreciated.
Thanks

eli_hoehandle,
Please give us the URL to this page so we can see what you mean more clearly. You are certainly not supposed to place the PHP statement in the CSS file; that doesn't make sense!
You just need a page with your header in called header.php. Then you need another page, index.php for example, which contains the following line of code <u>in the HTML</u>:
<?php include("header.php"); ?>
Make sure the header.php page isn't actually a full page, i.e. doesn't have:
<html>
<head>
<title>Header Page</title>
<head>
...
etcPost back here with the URL.
Thanks,
James

Can't post URL... not a public site, only internal. Below is a section of the index.php
include("../../header.php");include_once("../inc/config.php");
start_session();
include_once("../inc/database.php");
include_once("../inc/isuser.php");
include_once("../lang/".$LANG_setting.".php");
include_once("../inc/skins/".$SKIN_name."/config.hcl");
$SKIN_type = "tt";
$SKIN_inner = "default";
$MAIN = "";if ($TICKETS_login !== 1) {
if (isset($_GET["register"])) {
header("Location: ".$URL_maindir."/tt/user_login.php?".$sid."®ister=yes");
} else {
header("Location: ".$URL_maindir."/tt/user_login.php?".$sid);
}
exit;
}if (!isset($_GET["x"])) {
$MAIN .= "<table width=\"90%\" border=\"0\" align=\"center\" cellpadding=\"2\" cellspacing=\"0\" class=\"border\">
<tr bgcolor=\"".$TABLE_hcolour."\">
<td><div align=\"center\">[".$LANG_open_tickets."] [".$LANG_closed_tickets."]</div></td>
</tr>
<tr>
<td>
<table width=\"100%\" border=\"0\" cellspacing=\"1\" cellpadding=\"2\">
<tr bgcolor=\"".$TABLE_hcolour."\">
<td width=\"50\"> </td>
<td width=\"70\"><div align=\"center\">".$LANG_tid."</div></td>
<td><div align=\"center\">".$LANG_subject."</div></td>
<td width=\"200\"><div align=\"center\">".$LANG_time_reply."</div></td>
<td width=\"70\"><div align=\"center\">".$LANG_urgency."</div></td>
</tr>
</table>";$result_t = DATABASE_query("SELECT * FROM ".$DB_prefix."tickets WHERE username='$TICKETS_username' AND status='2' ORDER BY urgency DESC");
while($get = DATABASE_fetch($result_t)) {
$TICKET_foundo = 1;

I checked the Header.php file and removed all tags but the ones needed, but no change in results.
What I want is the header to be at the very top of the page...then a few lines down I want the PHP login box to be centered. The login page load correctly when the header is not included.
What I am getting is a few blank lines before the Header and then with no space in between I get the login box which is no longer centered, but on the left side. I can add line break commands into the login file but it adds the lines before the header and not in between the header and the login box the way I want it to be.

I am using an GPL program called Help Center Live and trying to customize the look to fit our needs. It is a Trouble ticket system. Thanks for the help so far. I am learning a lot working through this.

![]() |
![]() |
![]() |

This post is quite old and has been locked from receiving new replies. Please create a new posting instead.
| Ads by Google |