How can i style the message that comes when user did not fill in the form correct?

hi php people,

i have a question. i am using a simple php script to process a form. When the user forgets to fill in a field, and hits the submit button, there comes a message to fill in everything. But, this message is totally unstyled and a little ugly to look at. I have tried to give it a css class and i had put the styles on top of the php file. Unfortunately, when user hits the submit button, there comes an error message, that the header already has been sent. So, would there be a solution to this problem?

Here comes the php code to process the form. Beneath is the echo that gives the messages that i would like to style with some css.




$subject=“reservering accommodatie via”;

<body>Deze mail is verzonden via reserveren accommodatie<br />
<strong>Naam:</strong> $naam<br />
<strong>Achternaam is:</strong> $achternaam<br />
<strong>Taalkeuze:</strong> $taalkeuze<br />
<strong>Straat:</strong> $straat <strong>Nummer:</strong> $nummer<br />
<strong>Postcode:</strong> $postcode <strong>Woonplaats:</strong> $woonplaats<br />
<strong>Telefoonnummer:</strong> $telefoon<br />
<strong>Fax:</strong> $fax<br />
<strong>Emailadres:</strong> $email<br />
<strong>Aankomstdatum:</strong> $aankomst<br />
<strong>Vertrekdatum:</strong> $vertrek<br />
<strong>Type accommodatie</strong> $accommodatie<br />
<strong>Aantal volwassenen</strong> $aantalvolwassenen<br />
<strong>Aantal kinderen</strong> $aantalkinderen<br />
<strong>Hoe heeft u ons adres gevonden?</strong> $hoegevonden<br />
<strong>Wil zich aanmelden voor de nieuwsbrief:</strong> $nieuwsbrief<br />
<br />

$header="MIME-Version: 1.0
Content-Type: text/html; charset=iso-8859-1

Header(“Location: bedankt.html”);
}else {

echo "&lt;center&gt;&lt;div&gt;Graag alle verplichte velden invullen.&lt;br /&gt; Ga &lt;a href='javascript:history.back()'&gt;terug&lt;/a&gt; en probeer opnieuw.

<p>Folkshegeskoalle Schylgeralân</p></div></center>";
// how could i style the message after ‘echo’? inline does not work, with styles on top of page the script does not work…



Thanks a lot for any help!
for the information, the form is on this site:
reserveren accommodatie

Put the styles inline:

echo "<center><div style='font-family: arial; color: red">...";

Or put your <style> in the same block

} else {


echo "<center><div>...";

OH yes, because that’s ALWAYS good advice in someone’s markup… goes hand in hand with using the CENTER tag for Christmas only knows what reason… You might have to pull those stunts inside the e-mail, but normal HTML… that just ends up begging the question “WHAT IS THIS, 1997?!?”

… and we wonder why the markup output by server side code is outdated half-assed rubbish with advice like that on the table.

Give it a class – or semantic markup depending on what elements are around it, put it in the EXTERNAL stylesheet where it belongs, end of problem.

Though I have to ask why are you wasting memory on making copies of $_REQUEST… much less why are you using the insecure (since it reads $_GET) $_REQUEST instead of $_POST when there’s so much information involved… much less dragging execution down using double-quotes to build the string … much less building the string before you even know if you’re going to send it or not…

Or why you’re also using strong when those aren’t elements receiving emphasis, much less “more emphasis” – lemme guess, someone told you not to use B/I when they don’t realize it’s NOT the same as STRONG/EM?

Though this looks like a contact form, so I’d probably have action == the same PHP that outputs the form, so when it fails you can re-output the form populated instead of screwing around with “back”.

thanks guys for the advice!

actually i did not write the php code, but i will try to replace the $_request by $_post.

i’ll style the message…

have a good day,