Forum Moderators: coopster

Message Too Old, No Replies

PHP and CSS linking

css linking problem with php script

         

hades

1:00 pm on May 10, 2004 (gmt 0)

10+ Year Member



Ok, here comes the problem:

I have a php script to handle a form, if validation is ok, I send a mail and show the resulting information on the page.

I want the page to be formated with my css file. So my php script look like this:

<php script code>
<html code with css linking in header>

Everything is showed, but not formated. And I cannnot put the Header on top cause parts of the script requires that header must not been sent.

Any clue? Thanks

Netizen

1:20 pm on May 10, 2004 (gmt 0)

10+ Year Member



Perhaps you have the wrong path to your css file? Have you checked the server error logs?

I assume you have something like

<?php
<some code here>
?>
<html>
<head>
<title>my title</title>
<link rel="stylesheet" type="text/css" href="mystyles.css">
</head>
<body>
some text here
</body>
</html>

?

hades

12:04 pm on May 11, 2004 (gmt 0)

10+ Year Member



Exact, and I double-checked the path to my css file.
Relative or absolute, neither works but they both are correct.

Francis

12:37 pm on May 11, 2004 (gmt 0)

10+ Year Member



That's a little weird. This works for me but might entail additional work:

<link rel="stylesheet" type="text/css" href="<?php echo(SITE_ROOT)?>styles/800.css">

wherein I defined a settings.php containing something like:

<?php
ini_set(max_execution_time,"15");
define ("SITE_ROOT", "http://localhost/");
more php settings....
and still more of them here....
?>

Then I include the settings.php via

<?php
session_start();
require_once($_SERVER['DOCUMENT_ROOT'].'/settings.php');
--- or ---
require_once("settings.php");
.
.
.
more php codes...
?>

at the beginning of the php file.

Hope this helps.