Using your own PHPMailer, CSS and Javascript >> << Changing the captcha image style
To include a contact form into your page you need to insert a few simple lines of PHP into your HTML document.
For the form to work the web page should probably have a .php
extension.
The first piece of code needs to be inserted at the very beginning of the file. It is important that there are no other characters in front of it.
1 2 3 4 5 | <? php include_once 'php/SimpleContactForm/SimpleContactForm.php' ; SimpleContactForm ::initialize(); $contactForm = new SimpleContactForm ( 'default' ); ?> |
The code on line 2 include the SimpleContactForm script file in your document. The given path
(php/SimpleContactForm/SimpleContactForm.php
) should point to the location of the SimpleContactForm script
relative to your web page but this should work if you have kept the default folder structure.
Line 3 is required and has to be called before any other SimpleContactForm function can be used. For details about what
this function does see
SimpleContactForm.php - initialize
The code on line 4 creates a new form and stores a reference to it. This too should be called before any other form functions.
The name default
should be replaced with the name of the form you wish to create.
A new form should be created for each individual form that will be displayed on this page and each one needs to be
assigned a unique variable name :
$VARIABLE_NAME = new SimpleContactForm('FORM-NAME');
.
See SimpleContactForm.php for details.
The next piece of code must be inserted in the HTML head section which can be found between the opening and closing
<head>
tags.
This code includes all the CSS and Javascript files needed to display a form.
See SimpleContactForm.php - includeHeadHTML
for details.
1 | <? php SimpleContactForm ::includeHeadHTML(); ?> |
The last piece of code that needs to be included is the code that outputs the form's HTML code. This can be inserted
anywhere in the page between the <body>
tags and should be called for each form that needs to
be dsiplayed on the page.
1 | <? php $contactForm ->includeFormHTML(); ?> |
The code for an entire page with a form included is shown below :
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 | <? php // initialize() *MUST* be called only once before any forms are created // and *MUST* be called at the top of the page include_once 'php/SimpleContactForm/SimpleContactForm.php' ; SimpleContactForm ::initialize(); // Create a form name 'default'. All forms should be created // before SimpleContactForm::includeHeadHTML() is called and after SimpleContactForm::initialize() $contactForm = new SimpleContactForm ( 'default' ); ?> <! DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> < html > < head > <!-- MISC HEAD CONTENT --> <? php // This will include any files needed to display the contact form (CSS, Javascript) ?> <? php // This must be called only once inside the HTML <head> tag ?> <? php SimpleContactForm ::includeHeadHTML(); ?> </ head > < body > <!-- MISC HTML CONTENT --> <!-- ... --> <? php // Call this to output the form ?> <? php $contactForm ->includeFormHTML(); ?> <!-- MISC HTML CONTENT --> <!-- ... --> </ body > </ html > |
Using your own PHPMailer, CSS and Javascript >> << Changing the captcha image style