Reputation: 21
I'm working on a quote submission form for my company, and running into an issue with the form functionality (namely, the Submit button does nothing). Currently, the form is below:
<form action="quotethanks.php" form id="contact-form">
<fieldset>
<p>
<label class="name">
<input type="text" name="first" value="First Name:*">
<span class="errors"><span class="error">*This is not a valid name.</span> <span class="empty">*This field is required.</span></span></label>
<label class="name">
<input type="text" name="last" value="Last Name:*">
<span class="errors"><span class="error">*This is not a valid name.</span> <span class="empty">*This field is required.</span></span></label>
<label class="name">
<input type="text" name="business" value="Business Name:*">
<span class="errors"><span class="error">*This is not a valid name.</span> <span class="empty">*This field is required.</span></span></label>
<label class="email">
<input type="text" name="email" value="E-mail Address:*">
<span class="errors"><span class="error">*This is not a valid email.</span> <span class="empty">*This field is required.</span></span></label>
<label class="phone">
<input type="text" name="phone" value="Phone Number:*">
<span class="errors"><span class="error">*This is not a valid phone number.</span> <span class="empty">*This field is required.</span></span></label>
<label class="message"> Type of quote: *
<select name="type">
<option value="Display Case">Display Case</option>
<option value="Case Part"> Case Part</option>
<option value="Service"> Service</option>
<option value="Other"> Other</option>
</select></label>
<br><br>If "other," please define:
<textarea name="define" id="define"></textarea>
<br><Br>
<label class="name">
<input type="text" name="model" value="Equipment Model Number (if known)">
</label>
<label class="name">
<input type="text" name="serial" value="Equipment Serial Number (if known)">
</label>
Quote Description:
<textarea name="description" id="description"></textarea>
<br><br>
<label class="name">
<input type="text" name="offer" value="Offer Code (if applicable)">
</label>
<div class="clear"></div>
<div class="btns">
<a class="button" data-type="submit">Submit</a>
<a class="button" data-type="reset">Clear</a>
<div class="clear"></div>
</p>
</p>
</fieldset>
</form>
This should then send the entered data to quote_mailer.php, and then redirect to quotethanks.php (the last line of code):
<?php
/*Subject and email variables */
$emailSubject = 'Quote Request Submitted';
$webMaster = '[email protected]';
/* Gathering Data Variables */
$firstField = $_POST['first'];
$lastField = $_POST['last'];
$businessField = $_POST['business'];
$emailField = $_POST['email'];
$phoneField = $_POST['phone'];
$typeField = $_POST['type'];
$defineField = $_POST['define'];
$modelField = $_POST['model'];
$serialField = $_POST['serial'];
$descriptionField = $_POST['description'];
$offerField = $_POST['offer'];
$body = "<br><hr><br>";
$body.= "Name: ".$firstField." ".$lastField." <br>";
$body.= "Business Name: ".$businessField." <br>";
$body.= "Email: ".$emailField." <br>";
$body.= "Phone Number: ".$phoneField." <br>";
$body.= "Quote Type: ".$typeField." <br>";
$body.= "If other, define: ".$defineField." <br>";
$body.= "Model Number, if known: ".$modelField." <br>";
$body.= "Serial Number, if known: ".$serialField." <br>";
$body.= "Quote Description: ".$descriptionField." <br>";
$body.= "Offer Code: ".$offerField." <br>";
$headers = "From: ".$emailField."\r\n";
$headers .= "Content-type: text/html\r\n";
if(mail($webMaster, $emailSubject, $body, $headers))
header('Location: contact-form-thank-you.html');
?>
The issue I'm running into is on the form's actual page, all data gets entered, and then the Submit button does nothing. It shows up, you can click it, but for all visible purposes nothing happens. While I've worked with HTML more than a little, creating PHP-driven forms is relatively new to me so I'm not really seeing where in this code an issue might be.
Any direction would be greatly appreciated!
Upvotes: 0
Views: 971
Reputation: 23500
You need to use an input submit and not an anchor, so change this
<a class="button" data-type="submit">Submit</a>
To
<input class="button" type="submit" name="submit">Submit</a>
In your php code add instead a checking for isset()
of the button
if(isset($_POST['submit']))
{
$emailSubject = 'Quote Request Submitted';
$webMaster = '[email protected]';
//all your code here
} else {
//print the form
}
Upvotes: 1