Hello I’m new to phphelp so forgive me if I’m doing anything wrong. Also I have very little knowledge on php. So I have this contact form that I want to send to my email when the user submits it. I have been beating my head against the wall for a while now, both files are uploaded to the server, and are in the same directory. The form goes to the success page, but I get no email. help me please.
also the link to the form is http://xtcracingteam.com/apply.html if that helps.
this is the html
<form method="post" action="http://xtcracingteam.com/send_form_email.php">
<label class="first-name">
First Name
</label>
<input name="firstName" class="firstName" type="text" placeholder="Joe" required />
<label class="last-name">
Last Name
</label>
<input name="lastName" class="lastName" type="text" placeholder="Swanson" required/>
<label class="Race-number">
Race Number
</label>
<input name="raceNumber" class="raceNumber" type="text" placeholder="999" required/>
<label class="class">
Class
</label>
<input name="bikeClass" class="bikeClass" type="text" placeholder="Mx 450 Production A" required/>
<label class="age">
Age
</label>
<input name="personAge" class="personAge" type="text" placeholder="21" required/>
<label class="home-town">
Home Town
</label>
<input name="homeTown" class="homeTown" type="text" placeholder="Washougal Washington" required/>
<label class="Current-sponsors">
Current Sponsors
</label>
<textarea name="sponsors" placeholder="Gopro, Redbull, Scott..." class="currentSponsors" required></textarea>
<label class="recent-achievements">
Recent Achievements
</label>
<textarea name="recentAchievments" placeholder="I won this and that..." class="recentAchievments" required></textarea>
<label class="why">
Why should we pick you to represent our brand?
</label>
<textarea name="theWhy" placeholder="(hint: Dont say Cuz im the fastest)" class="theWhy" required></textarea>
<label class="email">
Email
</label>
<input name="email" class="email" type="email" placeholder="[email protected]" required/>
<input class="submit" type="submit" value="Submit!" />
</form>
this is the php code
<?php
if(isset($_POST['email'])) {
// EDIT THE 2 LINES BELOW AS REQUIRED
$email_to = "[email protected]";
$email_subject = “New Application”;
function died($error) {
// your error code can go here
echo "We are very sorry, but there were error(s) found with the form you submitted. ";
echo "These errors appear below.<br /><br />";
echo $error."<br /><br />";
echo "Please go back and fix these errors.<br /><br />";
die();
}
// validation expected data exists
if(!isset($_POST[‘firstName’]) ||
!isset($_POST['lastName']) ||
!isset($_POST['raceNumber']) ||
!isset($_POST['bikeClass']) ||
!isset($_POST['personAge']) ||
!isset($_POST['homeTown']) ||
!isset($_POST['sponsors']) ||
!isset($_POST['recentAchievments']) ||
!isset($_POST['theWhy']) ||
!isset($_POST['email'])) {
died('We are sorry, but there appears to be a problem with the form you submitted.');
}
$first_name = $_POST[‘first_name’]; // required
$last_name = $_POST[‘last_name’]; // required
$email_from = $_POST[‘email’]; // required
$raceNumber = $_POST[‘raceNumber’]; // required
$bikeClass = $_POST[‘bikeClass’]; // required
$personAge = $_POST[‘personAge’]; // required
$homeTown = $_POST[‘homeTown’]; // required
$sponsors = $_POST[‘sponsors’]; // required
$recentAchievments = $_POST[‘recentAchievments’]; // required
$theWhy = $_POST[‘theWhy’]; // required
$email_message = “Form details below.\n\n”;
function clean_string($string) {
$bad = array(“content-type”,“bcc:”,“to:”,“cc:”,“href”);
return str_replace($bad,"",$string);
}
$email_message .= “First Name: “.clean_string($firstName).”\n”;
$email_message .= “Last Name: “.clean_string($lastName).”\n”;
$email_message .= “Email: “.clean_string($email_from).”\n”;
$email_message .= “race number: “.clean_string($raceNumber).”\n”;
$email_message .= “bikeClass: “.clean_string($bikeClass).”\n”;
$email_message .= “personAge: “.clean_string($personAge).”\n”;
$email_message .= “homeTown: “.clean_string($homeTown).”\n”;
$email_message .= “sponsors: “.clean_string($sponsors).”\n”;
$email_message .= “recentAchievments: “.clean_string($recentAchievments).”\n”;
$email_message .= “theWhy: “.clean_string($theWhy).”\n”;
// create email headers
$headers = 'From: '.$email_from."\r\n".
'Reply-To: '.$email_from."\r\n" .
‘X-Mailer: PHP/’ . phpversion();
mail($email_to, $email_subject, $email_message, $headers);
?>
Thank you for contacting us. We will be in touch with you very soon.
return to XTCRacingTeam
<?php } ?>