Dreamweaver Contact form help

 

 

 

Creating a contact for for dreamveaver you need to create two files. On your actual .html files the other is the actual .php. I have called mine form.html, thankyou.html, and form.php. You should put all files in the same directory. Here is the code for the php file and html.

/* Form.php */

<?php

$EmailFrom = "info@caltechsys.com"; /* Email name sent from */
$EmailTo = "info@caltechsys.com";
/* Your email address sent to */
$Subject = "Website"; <Subject in the email sen t>
/* These are the information taken */
$First = Trim(stripslashes($_POST['First']));
/* from form. */
$Last = Trim(stripslashes($_POST['Last']));
$Company = Trim(stripslashes($_POST['Company']));
$Email = Trim(stripslashes($_POST['Email']));
$Telephone = Trim(stripslashes($_POST['Telephone']));
$Mobile = Trim(stripslashes($_POST['Mobile']));
$Comments = Trim(stripslashes($_POST['Comments']));

// validation
$validationOK=true;
if (Trim($First)=="") $validationOK=false;
/* Validation for three fields */
if (Trim($Last)=="") $validationOK=false;
if (Trim($Email)=="") $validationOK=false;
if (!$validationOK) {
print "<meta http-equiv=\"refresh\" content=\"0;URL=error.htm\">";
/* Calls error.htm form if error */
exit;
}

// prepare email body text
$Body = "";
$Body .= "First: ";
$Body .= $First;
$Body .= "\r";
$Body .= "Last: ";
$Body .= $Last;
$Body .= "\r";
$Body .= "Company: ";
$Body .= $Company;
$Body .= "\r";
$Body .= "Email: ";
$Body .= $Email;
$Body .= "\r";
$Body .= "Telephone: ";
$Body .= $Telephone;
$Body .= "\r";
$Body .= "Mobile: ";
$Body .= $Mobile;
$Body .= "\r";
$Body .= "Comments: ";
$Body .= $Comments;
$Body .= "\r";

// send email
$success = mail($EmailTo, $Subject, $Body, "From: <$EmailFrom>");

// redirect to success page
if ($success){
print "<meta http-equiv=\"refresh\" content=\"0;URL=thankyou.html\">";
}
else{
print "<meta http-equiv=\"refresh\" content=\"0;URL=error.htm\">";
}
?>

 

Download the form.php

Form.html

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Caltechsys - Computer Repair Houston TX, 77007</title>

</head>

<body>
<td width="54" height="190" align="left" valign="top">&nbsp;</td>
<td width="191" align="left" valign="top"><form method="post" action="form.php">
<span class="m"><span class="m">Fields marked (*) are required </span>
</span>
<p class="m"><span class="m">First:* <br />
<input type="text" name="First" />
</span></p>
<p class="m"><span class="m">Last:* <br />
<input type="text" name="Last" />
</span></p>
<p class="m"><span class="m">Company:<br />
<input type="text" name="Company" />
</span></p>
<p class="m"><span class="m">Email:*<br />
<input type="text" name="Email" id="Email" />
</span></p>
<p class="m"><span class="m">Telephone:<br />
<input type="text" name="Telephone" />
</span></p>
<p><span class="m"><span class="m">Comments:</span></span><br />
<textarea name="Comments" id="Comments"></textarea>
</p>
<p>
<input type="submit" name="submit" value="Submit" />
</p>
</form></td>
<body>
</html>

Here is my form:

Fields marked (*) are required

First:*

Last:*

Company:

Email:*

Telephone:

Comments: