Below is the php code starting from <!-- PHP CODE --> - copy, paste into new document and save it as - send_form.php
Change info@yourdomain.co.uk to your email address.
if the email goes through successfully it redirects to a success.html page (you have to create that with a message saying "Your email has been sent successfully". If it fails it redirects to a failure.html page (you have to create that with a failure message).
The email only gets sent IF all the form field are filled in which is what this line checks (if you want to allow a field to be empty then dont include it in the line of code)
if(!empty($the_name) || !empty($the_email) || !empty($vote) || !empty($choose_scale) || !empty($message))
There are other things you should do like check for a vaild email address but this will get you off the ground and running hopefully
<!-- PHP CODE -->
<?php
$email_from = "info@yourdomain.co.uk";
$email_to = "info@yourdomain.co.uk";
$subject = "Feedback from website";
$the_name = trim(stripslashes($_POST['the_name']));
$the_email = trim(stripslashes($_POST['the_email']));
$vote = trim(stripslashes($_POST['vote']));
$choose_scale = trim(stripslashes($_POST['choose_scale']));
$message = trim(stripslashes($_POST['message']));
// prepare email body text
$body .= "Name: $the_name\n";
$body .= "Email: $the_email\n";
$body .= "Vote: $vote\n";
$body .= "Scale: $choose_scale\n";
$body .= "Message: $message\n";
// send email
if(!empty($the_name) || !empty($the_email) || !empty($vote) || !empty($choose_scale) || !empty($message)) {
mail($email_to, $subject, $body, "From: <$email_from>");
// redirect to success page
header("Location: success.html");
}
else{
header("Location: failure.html");
}
?>
Below is the form html (I've amended it slightly)
<form action="send_form.php" method="post" name="form1" id="form1">
<fieldset>
<legend class="colour"><strong>Personal Information</strong></legend>
<p> <label class="question" for="the_name"> What is your name?</label>
<input type="text" id="the_name" name="the_name" placeholder="Enter your full name." size="50" required autofocus/> </p>
<p> <label class="question" for="the_email"> What is your email address?</label>
<input type ="email" id="the_email" name="the_email" placeholder="Please enter your email" size="50" required/> </p>
<p> </p>
</fieldset>
<fieldset>
<legend class="colour"><strong>Feedback</strong></legend>
<p><span class="question">Please chose the one that best suits your experience:</span><br/>
<input type="radio" id="vote_yes" name="vote" value="yes" checked />
<label for="vote_yes">Yes</label> <br/>
<input type="radio" id="vote_somewhat" name="vote" value="somewhat" checked />
<label for="vote_somewhat">Somewhat</label> <br/>
<input type="radio" id="vote_no" name="vote" value="No" checked />
<label for="vote_no">No</label> </p>
<p> </p>
</fieldset>
<fieldset>
<p>
<label for="choose_scale"><span class="question"><strong>What is your overall impression of the site on a scale of 1 (poor) to 10 (excellent):</strong></span></label>
<input type="number" id="choose_scale" name="choose_scale" min="0" max="10" step="1" value="5"/></p>
<p> </p>
</fieldset>
<fieldset>
<legend class="colour"><strong>Is there anything else you would like to say or ask?</strong></legend>
<p><label for="message"><span class="question">Let us know if you have any comments or suggestions as to how we can improve our site, or for any other queries.</span></label>
<textarea id="message" name="message" rows="7" cols="55">
</textarea></p>
</fieldset>
<div id="buttons">
<input type="submit" name="submit" value="Click here to submit" /> or
<input type="reset" value="Erase and start again" />
</div>
</form>