Implementing phpmail in FrontPage 2002/2003 contact forms
Our server architecture does not support contact forms created with FrontPage, using the webbot feature to submit form results. There is, however, a way for you to add a contact form on your website even if you have created it using FrontPage. You have to create a PHP contact form that uses the phpmail() function to send e-mails. This article explains how you can achieve this.
Start your FrontPage and show the 'Forms' toolbar.
To turn this toolbar on, go to View > Toolbars > Forms. You can also right-click on any current toolbar and select the Forms toolbar. You can move the toolbar around on your screen or dock it to the top, bottom, left or right.
First, you need to create a new form on the page where all the form elements will be placed (your contact page):
- With your cursor on the first line below the "Ask a Question:" header, click on the "Insert Form" button in the Forms toolbar. FrontPage inserts an empty form with a Submit and Reset button into your page.
- Right-click anywhere on your new form and choose Form Properties.
- Change the "Form Name:" to "contact"
- Click on the Options button.
- In the "Action:" box, type "form.php"
- Click OK to save your options.
- Click OK again to save your changes to the Form Properties.
When you are done, your HTML code should look like this:
<form method="POST" action="form.php" name="contact"><p><input type="submit" value="Submit" name="B1"><input type="reset" value="Reset" name="B2"></p> </form> Note that it is a very simple HTML code. In the future, it might be easier to edit the FORM tag directly in the HTML code rather than using the Form Properties window in FrontPage.
The form.php file should be placed in the same directory as the contact form and should contain the following code:
<?php $MailToAddress = "mail@my-best-domain.com"; // your email address - must be hosted with us, i.e. present in your E-Mail Manager$redirectURL = "thankyou.htm"; // the URL of the thank you page.
$MailSubject = "Contact Form"; // the subject of the message you will receive
$MailToCC = ""; // CC (carbon copy) also send the email to this address (leave empty if you won't use it)
$Message = "";
if (!is_array($HTTP_POST_VARS))
return;
reset($HTTP_POST_VARS);
while(list($key, $val) = each($HTTP_POST_VARS)) {
$GLOBALS[$key] = $val;
if (is_array($val)) {
$Message .= "<br><b>$key:</b> ";
foreach ($val as $vala) {
$vala =stripslashes($vala);
$Message .= "$vala, ";
}
$Message .= "<br>";
}
else {
$val = stripslashes($val);
if (($key == "Submit") || ($key == "submit")) { }
else { if ($val == "") { $Message .= "$key: - <br>"; }
else { $Message .= "<b>$key:</b> $val<br>"; }
}
}
} // end while
$Message = "\n<font face=verdana size=2>".$Message;
mail( $MailToAddress, $MailSubject, $Message, "Content-Type: text/html; charset=ISO-8859-1\r\nFrom: ".$email."\r\nBCc: ".$MailToCC);
header("Location: ".$redirectURL);
?>