Hi, I’m trying to get my order form to work with php to send information to the email I specify. I got the tutorial from this site and I’m doing everything it says to make it work, but obviously something is wrong. Every time I go to submit the information I get my error message saying the data did not send. Could somebody please take a look at my code and point me in the right direction? Thanks in advance. I’m new to coding like this, I’m a designer and I usually just stick to html and CSS.
Here is my html code:
<form method="POST" action="mailer.php">
<h4>Step 1 – Choose Wood finish</h4>
<input name="check[]" type="checkbox" value="natural_cherry" />
Natural Cherry <br />
<input name="check[]" type="checkbox" value="dark_cherry" />
Dark Cherry <br />
<input name="check[]" type="checkbox" value="custom" />
Custom
<input type="text" size="30" maxlength="40" name="custominput" />
<br />
<h4>Step 2 – Choose Top Type</h4>
<input name="check[]" type="checkbox" value="type0top" />
Type 0 Top <br />
<input name="check[]" type="checkbox" value="type1topleft" />
Type 1 Top Laptop Tray Left<br />
<input name="check[]" type="checkbox" value="type1topright" />
Type 1 Top Laptop Tray Right<br />
<input name="check[]" type="checkbox" value="type2top" />
Type 2 Top
<br />
<h4>Step 3 – Choose Desk Style</h4>
<input name="check[]" type="checkbox" value="ART_series" />
ART Series Desk<br />
<input name="check[]" type="checkbox" value="TEC_series" />
TEC Series Desk
<br />
<h4>Step 4 – Choose Functional Desk Accessories</h4>
<input name="check[]" type="checkbox" value="computer_shelf" />
Computer Shelf (standard desk comes with 1 computer shelf) <br />
<input name="check[]" type="checkbox" value="printer_shelf" />
Printer Shelf<br />
<input name="check[]" type="checkbox" value="return_desk" />
Return Desk <br />
<input name="check[]" type="checkbox" value="desk_file_cabinet" />
Desk File Cabinet
<br />
<h4>Step 5 – Choose Office Accessories</h4>
<input name="check[]" type="checkbox" value="hutch" />
Hutch <br />
<input name="check[]" type="checkbox" value="book_case" />
Book Case <br />
<input name="check[]" type="checkbox" value="conference_table" />
Conference Table <br />
<input name="check[]" type="checkbox" value="desk_file_cabinet" />
Desk File Cabinet <br />
<input name="check[]" type="checkbox" value="meeting_table" />
Meeting Table
<br />
<hr />
<h4>Contact Information</h4>
<p>
<span2>* All fields required</span2>
</p>
<br />
<label>Full Name: <span2>*</span2></label><br /><input type="text" size="30" maxlength="40" name="name" />
<br />
<label>Address: <span2>*</span2></label><br />
<input type="text" size="30" maxlength="40" name="address" />
<br />
<label>Phone: <span2>*</span2></label><br />
<input type="text" size="30" maxlength="40" name="phone" />
<br />
<label>Email: <span2>*</span2></label><br />
<input type="text" size="30" maxlength="40" name="email" />
<br />
<label>Message: <span2>*</span2></label><br />
<textarea rows="6" cols="25" maxlength="1000" name="message"></textarea>
<br /><input width="50px" type="submit" value="Submit" id="submit_btn" name="" />
</form>
and my php code:
<?php
if(isset($_POST['submit'])) {
$to = "myemail@email.com";
$subject = "Form Tutorial";
$name_field = $_POST['name'];
$address_field = $_POST['address'];
$phone_field = $_POST['phone'];
$email_field = $_POST['email'];
$message = $_POST['message'];
foreach($_POST['check'] as $value) {
$check_msg .= "Checked: $value
";
}
$body = "From: $name_field
Address: $address_field
Phone: $phone_field
E-Mail: $email_field
$check_msg Message:
$message
";
echo "Data has been submitted to $to!";
mail($to, $subject, $body);
} else {
echo "Error, data did not send";
}
?>