.php form won't submit to email or redirect
Hello,
I have created an html form that is designed to do two things - submit form information to a specified email address and redirect users to another page on the site. I created a .php form to manage these actions. I got to a point where the redirect was successful, but the email was not. In attempting to fix this, the form now does neither...
I am completely new to web development, but would appreciate any insight you can provide. Thank you!
PHP
<?php
if(isset($_POST['submit'])){
$to = 'example@example.com';
$subject = 'Whitepaper Request Form';
$email_message = 'Results from Whitepaper Request Form:\n\n';
$headers = 'From: example@example.com';
}
function clean_string($string) {
$bad = array("content-type","bcc:","to:","cc:","href");
return str_replace($bad,"",$string);
}
$email_message .= "First Name: ".clean_string($_POST['First_Name'])."\n";
$email_message .= "Last Name: ".clean_string($_POST['Last_Name'])."\n";
$email_message .= "Address: ".clean_string($_POST['Address'])."\n";
$email_message .= "City: ".clean_string($_POST['City'])."\n";
$email_message .= "State: ".clean_string($_POST['State'])."\n";
$email_message .= "Zip: ".clean_string($_POST['Zip'])."\n";
$email_message .= "Phone: ".clean_string($_POST['Phone'])."\n";
$email_message .= "Email: ".clean_string($_POST['Email'])."\n";
$email_message .= "Company: ".clean_string($_POST['Company'])."\n";
$email_message .= "Title: ".clean_string($_POST['Title'])."\n";
mail($to,$subject,$email_message,$headers);
header('Location: ExampleRetro_WhtP.pdf');
?>
HTML
<section>
<div class="row">
<div class="col-lg-offset-3 col-lg-6 col-md-12"><form name="Whitepaper Request form" method="POST" action="Info-Request.php" class="text-center">
<input name="First_Name" type="text" required class="contact-field-sm" id="fname" placeholder="First Name">
<input name="Last_Name" type="text" required class="contact-field-sm" id="lname" placeholder="Last Name"><br><br>
<input name="Address" type="text" class="contact-field-sm" id="address" placeholder="Address">
<input name="City" type="text" class="contact-field-sm" id="city" placeholder="City"><br><br>
<input name="State" type="text" class="contact-field-sm" id="state" placeholder="State">
<input name="Zip" type="text" class="contact-field-sm" id="zip" placeholder="Zip"><br><br>
<input name="Phone" type="tel" class="contact-field-sm" id="phone" placeholder="Phone">
<input name="Email" type="email" class="contact-field-sm" id="email" placeholder="Email"><br><br>
<input name="Company" type="text" required class="contact-field-sm" id="company" placeholder="Company">
<input name="Title" type="text" required class="contact-field-sm" id="title" placeholder="Title"><br><br>
<input id="submit" type="submit" name="submit" value="Submit">
</form>
