Jump to content

Welcome to Geeks to Go - Register now for FREE

Need help with your computer or device? Want to learn new tech skills? You're in the right place!
Geeks to Go is a friendly community of tech experts who can solve any problem you have. Just create a free account and post your question. Our volunteers will reply quickly and guide you through the steps. Don't let tech troubles stop you. Join Geeks to Go now and get the support you need!

How it Works Create Account
Photo

need help for form to email


  • Please log in to reply

#1
clarky23

clarky23

    Member

  • Member
  • PipPip
  • 59 posts
I can use a little help fixing a form for a client. I believe I have the form right, but when I load the file, fill the form out and hit submit, the form clears, and no email with information arrived. Any assistance will be appreicated. Below is the code (php) Thanks in advance.

<?php include_once('header.inc'); ?>
<?php if(isset($_POST['email'])) {

// EDIT THE 2 LINES BELOW AS REQUIRED
$email_to = "[email protected]";
$email_subject = "Information from Williams Roofing Website";


function died($error) {
// your error code can go here
echo "We are very sorry, but there were error(s) found with the form your submitted. ";
echo "These errors appear below.<br /><br />";
echo $error."<br /><br />";
echo "Please go back and fix these errors.<br /><br />";
die();
}

// validation expected data exists
if(!isset($_POST['name']) ||
!isset($_POST['address1']) ||
!isset($_POST['address2']) ||
!isset($_POST['city']) ||
!isset($_POST['state']) ||
!isset($_POST['zipcode']) ||
!isset($_POST['county']) ||
!isset($_POST['homephone']) ||
!isset($_POST['workphone']) ||
!isset($_POST['cellphone']) ||
!isset($_POST['email_from']) ||
!isset($_POST['comments'])) {
died('We are sorry, but there appears to be a problem with the form your submitted.');
}

$name = $_POST['name']; // not required
$address1 = $_POST['address1']; // notrequired
$address2 = $_POST['address2']; // not required
$address1 = $_POST['city']; // not required
$address1 = $_POST['state']; // not required
$address1 = $_POST['zipcode']; // not required
$address1 = $_POST['county']; // not required
$address1 = $_POST['homephone']; // not required
$address1 = $_POST['workphone']; // not required
$address1 = $_POST['cellphone']; // not required
$email_from = $_POST['email_from']; // not required
$comments = $_POST['comments']; // not required

$error_message = "";
$email_exp = "^[A-Z0-9._%-]+@[A-Z0-9.-]+\.[A-Z]{2,4}$";
if(!eregi($email_exp,$email_from)) {
$error_message .= 'The Email Address you entered does not appear to be valid.<br />';
}
$string_exp = "^[a-z .'-]+$";
if(!eregi($string_exp,$name)) {
$error_message .= 'The name you entered does not appear to be valid.<br />';
}
if(!eregi($string_exp,$address1)) {
$error_message .= 'The address you entered does not appear to be valid.<br />';
}
if(strlen($comments) < 2) {
$error_message .= 'The Comments you entered do not appear to be valid.<br />';
}

if(strlen($error_message) > 0) {
died($error_message);
}
$email_message = "Form details below.\n\n";

function clean_string($string) {
$bad = array("content-type","bcc:","to:","cc:","href");
return str_replace($bad,"",$string);
}

$email_message .= "Name: ".clean_string($name)."\n";
$email_message .= "Address1: ".clean_string($address1)."\n";
$email_message .= "Address2: ".clean_string($address2)."\n";
$email_message .= "city: ".clean_string($city)."\n";
$email_message .= "state: ".clean_string($state)."\n";
$email_message .= "zipcode: ".clean_string($zipcode)."\n";
$email_message .= "county: ".clean_string($county)."\n";
$email_message .= "homephone: ".clean_string($homephone)."\n";
$email_message .= "workphone: ".clean_string($workphone)."\n";
$email_message .= "cellphone: ".clean_string($cellphone)."\n";
$email_message .= "Email_from: ".clean_string($email_from)."\n";
$email_message .= "Comments: ".clean_string($comments)."\n";


// create email headers
$headers = 'From: '.$email_from."\r\n".
'Reply-To: '.$email_from."\r\n" .
'X-Mailer: PHP/' . phpversion();
@mail($email_to, $email_subject, $email_message, $headers);
?>

<!-- include your own success html here -->

Thank you for contacting us. We will be in touch with you very soon.

<?
}
?>

<h4>CALL US FOR OUR SPECIALS OR FILL OUT THE FORM BELOW!</h4>
<form name="contactform" method="post" action="contact.php">
<table width="550px" border="0">
</tr>
<tr>
<td valign="top">
<label for="name">Name *</label>
</td>
<td valign="top">
<input type="text" name="name" maxlength="75" size="50">
</td>
</tr>

<tr>
<td valign="top"">
<label for="address1">Address 1*</label>
</td>
<td valign="top">
<input type="text" name="address1" maxlength="75" size="50">
</td>
</tr>

<tr>
<td valign="top"">
<label for="address2">Address 2*</label>
</td>
<td valign="top">
<input type="text" name="address2" maxlength="75" size="50">
</td>
</tr>

<tr>
<td valign="top"">
<label for="city">City*</label>
</td>
<td valign="top">
<input type="text" name="city" maxlength="75" size="50">
</td>
</tr>

<tr>
<td valign="top"">
<label for="state">State*</label>
</td>
<td valign="top">
<input type="text" name="state" maxlength="75" size="10">
</td>
</tr>

<tr>
<td valign="top"">
<label for="zipcode">ZIP*</label>
</td>
<td valign="top">
<input type="text" name="zipcode" maxlength="75" size="10">
</td>
</tr>

<tr>
<td valign="top">
<label for="county">County</label>
</td>
<td valign="top">
<select name="county" id="county">
<option value="" selected="selected"></option>
<option value="Richmond">Richmond</option>
<option value="Columbia">Columbia</option>
<option value="Aiken">Aiken</option>
</select>
</td>
</tr>

<tr>
<td valign="top">
<label for="email_from">Email Address</label>
</td>
<td valign="top">
<input type="text" name="email_from" maxlength="80" size="50">
</td>
</tr>

<tr>
<td valign="top">
<label for="type">Type of Work Requested</label>
</td>
<td>
<select name="type" id="type">
<option value="" selected="selected"></option>
<option value="New">New</option>
<option value="Replacement">Replacement</option>
<option value="Repair">Repair</option>
<option value="Other">Other</option>
</select>
</td>
</tr>

<tr>
<td valign="top">
<label for="comments">Description (if other) and/or other comments</label>
</td>
<td valign="top">
<textarea name="comments" maxlength="4000" cols="50" rows="10"></textarea>
</td>
</tr>

<tr>
<td colspan="2" style="text-align:center">
<input type="submit" value="Submit Form"> <a href="http://www.freeconta..._form.php"></a>
</td>
</tr>
</table>
</form>

<p>Please use one of the methods below to get in touch with us:</p>
<p>By Phone:</p>
<ul>
<li>South Carolina: 803-644-ROOF (7663)</li>
<li>Georgia: 706-722-7664</li>
</ul>
<p>If you would prefer to mail us, our mailing address is<br /><br />
P.O. Box 1830<br />
Langley, SC 29834</p>
</ul>
<p>You can always email us at <a href="mailto:[email protected]">[email protected]</a>.</p>
<?php include_once('footer.inc'); ?>
  • 0

Advertisements


#2
Joshua Baker

Joshua Baker

    New Member

  • Member
  • Pip
  • 8 posts
Hey

I will take a look at this in about 3 hours after i finish this ecommerce site. Thanks

Joshua
  • 0

#3
clarky23

clarky23

    Member

  • Topic Starter
  • Member
  • PipPip
  • 59 posts
Joshua,
Thanks for the offer, but i was able to get assistance this weekend. I just hadn't closed the thread yet.
Michael
  • 0

#4
Joshua Baker

Joshua Baker

    New Member

  • Member
  • Pip
  • 8 posts
Awesome!
  • 0






Similar Topics

0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users

As Featured On:

Microsoft Yahoo BBC MSN PC Magazine Washington Post HP