Enquiry Form

HTML forms have two major parts, the form itself and an action file - the form processor.  And, to make sure you get sensible data back from your form, it's usual to have some sort of validation - a small javascript function to check that, at the very least, the enquirer has filled in all the mandatory fields. 

Enquiry Form HTML

Create a Raw/HTML Item in your website then copy & paste the HTML below into it to create the form.

[ select all ]

The form validation function, bValidateForm() is contained in the javascript file pp_top.js which you should already have included in your web pages - in the head section.  (This is already included in all PanPage themes.)

Styling the Form with CSS

Copy and paste the following into your CSS file to style the form.  (Note that you don't need this step if you're using a ready-made theme as it's already included in all PanPage themes.)

[ select all ]

Lines 1-4 style the text input and textarea fields giving them a fixed width and Courier New fixed width font.  Ordinarily input and textarea fields have a different font which makes the form look a bit disjointed.  Line 2 prevents the textarea from being resized on browsers that support CSS3

Line 6 styles the label fields giving them a width of 6em, and line 5 places the submit button just under the last field on the left.

Note that IE6 doesn't recognise these styles and will use the size and rows.cols attributes to determine the width and height of the text and textarea fields.

Form Processing

When you hit the 'submit' button the form's data is wrapped up in an 'HTTP request' and sent to the URL specified in the 'action' attribute.  PanPage themes all include a form processing file called act_sendmessage.php that also lets your site visitor know their message has been sent, but if you're building your own you can use the PHP code below.

To use it, create an 'excluded fixed page' called act_sendmessage.php and copy and paste the PHP code below in place of the WriteBody(); line...

[ select all ]

Remember to enclose the above in <?php ... ?> tags if your file is in HTML.

There's a lot there but in essence the PHP code checks that it has received the correct form data and then passes it thru a sanitizer function to ensure that the enquirer has not embedded any MIME codes to try to hijack your mailserver.  While it's doing that the sanitizer also checks for multiple links and email addresses which usually come from porn or drug pedlars trying to get links back to their websites.

The sSanitize() function takes two arguments, the text string to be sanitized and a flag telling it what's allowed and what's not...

FORBID_ALL: squashes any links or email addresses
ALLOW_EMAIL_ADDR: allows email addresses but squashes links
ALLOW_ALL: allows both email addresses AND links but no more than three at a time

If the input text is OK sSanitize() sends it back to you untouched, but if it finds anything that's not allowed, it returns a warning message, eg. "contained more than 3 links" and sets a flag (tested by the bIsUnsanitary() function).  The result is that you get a message telling you what happened and your mail server is protected from internet low-life!

The above code requires a valid SMTP mail account to send form messages to you.  Some servers will allow the use of the PHP mail() function but this is increasingly being disabled for security reasons.  You should enter valid email account details in the PanPage config file, pp_config.php.

This website uses cookies for statistical usage data. By continuing to use this site, you agree to the use of cookies.

Don't show this again