if($firstname == '') {print "You have not entered your first name, please go back and try again.";}

How do I make the text look like the entire site?
Or even better - is it possible to get a popup window on this instead of opening a full sized page?

Thank you!

Member Avatar
diafol
if($firstname == '') {print "You have not entered your first name, please go back and try again.";}

How do I make the text look like the entire site?
Or even better - is it possible to get a popup window on this instead of opening a full sized page?

Thank you!

echo "<p>You have not entered your first name, please go back and try again.</p>";

Will give you a the same styling as your normal paragraphs. Note you can use either 'print' or 'echo'. Well, as long as you have a css file or a <style> tag in your head area.

Popups are not suggested. They annoy the hell out of people. An inline message (perhaps in red) is far more effective.

Oh, thank you!
And how are the inline messages done?

Member Avatar
diafol

Inline messages usually take the form of ajax/javascript calls OR can be called via querystring (js free) from the form handler page:

pseudocode
on error - note error id (your choice)
send header to form page with querystring: ....form.php?error_id=4
in the form page, a conditional statement looks out for the $_GET variable - if present spits out a message in the appropriate place on the form.

If you get this to work, then consider using binary to identify multiple errors - you still only need to have the one querystring parameter.

Simple inline messages are usually javascript affairs which do not involve the server. They offer a quick and dirty way to validate form entry. However, js can easily be fooled and malicious data can be sent to your server and cause mayhem if it does not encounter server-side validation.

JS validation can occur one field at a time, as the focus is lost from a control. This has adv's and disadv's.

There are a number of good JS validators out there. I used to use YAV, but I'm sure there are a lot of other good ones available by now.