What's wrong with this? <form method="post" action="recieved.php"> <h2><span>Personal Info</span></h2> <p><label>First Name</label> <input type="text" id="f_name" name="f_name" class="text_field required" /></p> <p><label>Last Name</label> <input type="text" id="l_name" name="l_name" class="text_field required" /></p> <p><label>E-mail Address</label> <input type="text" id="email" name="email" class="text_field required email" /></p> <p><label>Company</label> <input type="text" id="company" name="company" class="text_field required" /></p> <p><label>Website</label> <input type="text" id="website" name="website" class="text_field required" /></p> <div class="clear margin"></div> <h2><span>Extra Details</span></h2> <p> <label>Budget</label> <input type="text" id="budget" name="budget" class="text_field" /></p> <p> <label>Promo Code</label> <input type="text" id="promo" name="promo" class="text_field" /></p> <p> <label>Referral</label> <input type="text" id="referral" name="referral" class="text_field" /></p> <p> </p> <div class="clear"></div><div class="send_form"> <input type="image" src="images/send.png" value="Submit" alt="Submit"> </div> </form> Code (markup): PHP <?php if(isset($_POST['submit'])) { $to = "my@email.com"; $subject = "Title"; $name_field1 = $_POST['f_name']; $name_field2 = $_POST['l_name']; $email_field = $_POST['email']; $company = $_POST['company']; $website = $_POST['website']; $budget = $_POST['budget']; $promo = $_POST['promo']; $referral = $_POST['referral']; $body = "Full Name: $name_field1 name_field2\n E-Mail: $email_field\n Company: $company\n Website: $website\n Budget: $budget\n Promo: $promo\n Referral: $referral4\n"; mail($to, $subject, $body); } else { echo "Quote not sent. Please try again!"; } ?> PHP:
First, name the form: <form method="post" action="recieved.php" name="coolform"> I did not check whether the information for the $_POST is got correctly from the form, but I can suggest a better PHP code. Be sure to protect the form from XSS too. It is not protected at the moment. What if you did like this: <?php if($_POST['coolform']) { $to = "my@email.com"; $subject = "Title"; $name_field1 = $_POST['f_name']; $name_field2 = $_POST['l_name']; $email_field = $_POST['email']; $company = $_POST['company']; $website = $_POST['website']; $budget = $_POST['budget']; $promo = $_POST['promo']; $referral = $_POST['referral']; $body = "Full Name: $name_field1 name_field2\n E-Mail: $email_field\n Company: $company\n Website: $website\n Budget: $budget\n Promo: $promo\n Referral: $referral4\n"; if (mail($to, $subject, $body)) { echo 'mail() Success!' . "<br />\n"; } else { echo 'mail() Failure!' . "<br />\n"; } } ?> Code (markup):
Err, what does "doesn't work" mean? It would be better to know the exact problem. Doesn't it send the email? Doesn't it have the correct variables in the $_POST array? Doesn't it send the last name in the mail body because you missed the '$' sign before the 'name_field2' var? Does it return with an error or warning?
Try changing the PHP code to this: <?php if($_POST) { $to = "my@email.com"; $subject = "Title"; $name_field1 = $_POST['f_name']; $name_field2 = $_POST['l_name']; $email_field = $_POST['email']; $company = $_POST['company']; $website = $_POST['website']; $budget = $_POST['budget']; $promo = $_POST['promo']; $referral = $_POST['referral']; $body = "Full Name: $name_field1 name_field2\n E-Mail: $email_field\n Company: $company\n Website: $website\n Budget: $budget\n Promo: $promo\n Referral: $referral4\n"; if (mail($to, $subject, $body)) { echo 'mail() Success!' . "<br />\n"; } else { echo 'mail() Failure!' . "<br />\n"; } } ?> Code (markup): If you leave the action like shown below it gives the message mail() Success! <form method="post" action="/" name="coolform">
Yep, works, because you missed the name="submit" form the input: <input type="image" src="images/send.png" value="Submit" alt="Submit" name="submit"> HTML: So the original script should work by adding this one.