I'm attempting to create an HTML5 form that submits basic vendor information without opening the user's email client, and with a "Submitted" (or something of the like) confirmation message as the form submits. From my research, I've found that I'd need to use PHP for this, but I'm clueless as to how to implement the PHP scripts.
Here's my form:
<form id="vendorInfo" action="process_form_vendor.php" method="post">
<label for="vendorName">Vendor Name:</label>
<br />
<input id="vendorName" name="vendorName" type="text" maxlength="30" required>
<br />
<label for="contactName">Contact Name:</label>
<br />
<input id="contactName" name="contactName" type="text" maxlength="35" required>
<br />
<label for="vendorType">Organization Type:</label>
<br />
<select id="vendorType" name="vendorType">
<option value="carrier">
Insurance Carrier
</option>
<option value="tech_crm">
Technology/CRM Management
</option>
<option value="leadProvider">
Lead Provider
</option>
<option value="info_comm">
Information/Communication
</option>
<option value="other">
Other (please describe below)
</option>
</select>
<br />
<label for="other1">Other Organization Type:</label>
<br />
<input id="other1" name="other1" type="text" maxlength="25">
<br />
<label for="email">Email:</label>
<br />
<input id="email" name="email" type="email" maxlength="30" required>
<br />
<label for="phone">Phone:</label>
<br />
<input id="phone" name="phone" type="tel" maxlength="12" required placeholder="xxx-xxx-xxxx">
<br />
<label for="questions">Any questions or comments? Leave them here:</label>
<br />
<textarea id="questions" name="questions" rows="10" maxlength="300"></textarea>
<br />
<br />
<fieldset id="selectionBox">
<legend id="packageSelect">
The following sponsorship packages are available for the Sales Summit; contact <a href="example@domain.com">Amanda</a> for pricing and details:
</legend>
<input type="radio" name="packageSelect" value="Bronze Package" checked> Bronze
<br />
<br />
<input type="radio" name="packageSelect" value="Silver Package"> Silver
<br />
<br />
<input type="radio" name="packageSelect" value="Gold Lunch Package"> Gold (breakfast; exclusive sponsorship)
<br />
<br />
<input type="radio" name="packageSelect" value="Gold Breakfast Package"> Gold (lunch; exclusive sponsorship)
<br />
<br />
<input type="radio" name="packageSelect" value="Gold Trade Show Package"> Gold (trade show; exclusive sponsorship)
</fieldset>
<br />
<button type="submit">Submit</button> <button type="reset">Reset</button><br />
And here is the PHP script I've written:
<?php
if(!isset($_POST['submit']))
{
echo "error; you need to submit the form!";
}
$vendorName = $_POST['vendorName'];
$contactName = $_POST['contactName'];
$vendorType = $_POST['vendorType'];
$other1 = $_POST['other1'];
$email = $_POST['email'];
$phone = $_POST['phone'];
$questions = $_POST['questions'];
$packageSelect = $_POST['packageSelect'];
if (empty($vendorName)||(empty($contactName)||(empty($vendorType)||(empty($email)||(empty($phone)||(empty($packageSelect)) {
echo "Vendor Name, Contact Name, Vendor Type, Email, Phone, and Package Selection are mandatory!";
exit;
}
$email_from = 'example@domain.com';
$email_subject = '2014 SMS Sales Summit - New Vendor Reservation Request';
$email_body = "You have received a new vendor reservation request for the 2014 SMS Sales Summit from $contactName at $vendorName.\n".
"Vendor Type: $vendorType\n".
"Other Vendor Type: $other1\n".
"Email Address: $email\n".
"Phone Number: $phone\n".
"Additional Questions: $questions\n".
"Sponsorship Level: $packageSelect\n".
$to = 'example@domain.com';
$headers = "$email_from \r\n";
$headers .= "Reply-To: $email \r\n";
mail($to,$email_subject,$email_body,$headers);
header('Location: thank-you.html');
?>
I'm pretty sure that I've got everything set up correctly to pull the information submitted into the 'input' fields, but I'm not sure if I've implemented this correctly for the radio buttons and the drop down selector. Any help with this implementation would be most appreciated. Thanks!