Hi I have a radio button form made in bootstrap, I want to know what the server side code needs to be in order to send a email to my email with the forms result.
I want the user to fill in the form ( radio buttons )and then click submit,
When he clicks submit a new window must open that says for instance "thank you please enter email below to get results"
Then there must be a field that I will ad that asks for the email and then a get result button.
I want to send the results of the radio buttons with the corresponding answers(selection) from the mail they submitted to my email.
to be receive it like this for example:
From: the entered email
Date:
To: my email
Subject: Survey Results
Question 1 Yes
Question 2 No
etc etc
Here is the code I use for the HTML side:
<div class="container">
<form class="form-horizontal action="contactmail.php" method="post" id="form">
<fieldset>
<!-- Form Name -->
<legend><b style="color:red">Quick Survey</b></legend>
<!-- Multiple Radios -->
<div class="control-group">
<label class="control-label" for="radios">Were you injured in a car or taxi accident?</label>
<div class="controls">
<label class="radio" for="radios-0">
<input type="radio" name="Question 1" id="radios-0" value="Yes">
Yes
</label>
<label class="radio" for="radios-1">
<input type="radio" name="Question 1" id="radios-1" value="No">
No
</label>
</div>
</div>
<!-- Multiple Radios -->
<div class="control-group">
<label class="control-label" for="radios">Was it within the past 3 years?</label>
<div class="controls">
<label class="radio" for="radios-0">
<input type="radio" name="Question 2" id="radios-0" value="Yes">
Yes
</label>
<label class="radio" for="radios-1">
<input type="radio" name="Question 2" id="radios-1" value="No">
No
</label>
</div>
</div>
<!-- Multiple Radios -->
<div class="control-group">
<label class="control-label" for="radios">Did you have serious injuries?</label>
<div class="controls">
<label class="radio" for="radios-0">
<input type="radio" name="Question 3" id="radios-0" value="Yes">
Yes
</label>
<label class="radio" for="radios-1">
<input type="radio" name="Question 3" id="radios-1" value="no">
no
</label>
</div>
</div>
<!-- Multiple Radios -->
<div class="control-group">
<label class="control-label" for="radios">Were you in hospital because of the accident?</label>
<div class="controls">
<label class="radio" for="radios-0">
<input type="radio" name="Question 4" id="radios-0" value="Yes">
Yes
</label>
<label class="radio" for="radios-1">
<input type="radio" name="Question 4" id="radios-1" value="No">
No
</label>
</div>
</div>
<!-- Multiple Radios -->
<div class="control-group">
<label class="control-label" for="radios">How many days did you spend in hospital?</label>
<div class="controls">
<label class="radio" for="radios-0">
<input type="radio" name="Question 5" id="radios-0" value="1 Day">
1 Day
</label>
<label class="radio" for="radios-1">
<input type="radio" name="Question 5" id="radios-1" value="1-7 Days">
1-7 Days
</label>
<label class="radio" for="radios-2">
<input type="radio" name="Question 5" id="radios-2" value="7-14 Days">
7-14 Days
</label>
<label class="radio" for="radios-3">
<input type="radio" name="Question 5" id="radios-3" value="14-21 Days">
14-21 Days
</label>
<label class="radio" for="radios-4">
<input type="radio" name="Question 5" id="radios-4" value="21-28 Days">
21-28 Days
</label>
<label class="radio" for="radios-5">
<input type="radio" name="Question 5" id="radios-5" value="1 Month or more">
1 Month or more
</label>
</div>
</div>
<!-- Multiple Radios -->
<div class="control-group">
<label class="control-label" for="radios">Did you undergo surgery?</label>
<div class="controls">
<label class="radio" for="radios-0">
<input type="radio" name="Question 6" id="radios-0" value="Yes">
Yes
</label>
<label class="radio" for="radios-1">
<input type="radio" name="Question 6" id="radios-1" value="No">
No
</label>
</div>
</div>
<!-- Multiple Radios -->
<div class="control-group">
<label class="control-label" for="radios">Do you still suffer as a result of the accident?</label>
<div class="controls">
<label class="radio" for="radios-0">
<input type="radio" name="Question 7" id="radios-0" value="Yes">
Yes
</label>
<label class="radio" for="radios-1">
<input type="radio" name="Question 7" id="radios-1" value="No">
No
</label>
</div>
</div>
<!-- Button -->
<div class="control-group">
<label class="control-label" for="Submit"></label>
<div class="controls">
<button id="Submit" name="Submit" class="btn btn-info">Submit</button>
</div>
</div>
</fieldset>
</form>
</div>
I will appreciate all the help
edit: It works now, here is the code i used ( Keep in mind trim is not needed )
<?php
/**
if(isset($_POST['submit'])) {
if (empty($_POST['email']) || empty($_POST['Question1']) || empty($_POST['Question2']) || empty($_POST['Question3']) || empty($_POST['Question4']) || empty($_POST['Question5']) || empty($_POST['Question6']) || empty($_POST['Question7'])) {
$error = true;
}
else {
**/ $email = trim($_POST['email']);
$to = "Enteryourmail@domain.co.za,$email";
$Question1 = trim($_POST['Question1']);
$Question2 = trim($_POST['Question2']);
$Question3 = trim($_POST['Question3']);
$Question4 = trim($_POST['Question4']);
$Question5 = trim($_POST['Question5']);
$Question6 = trim($_POST['Question6']);
$Question7 = trim($_POST['Question7']);
$email = trim($_POST['email']);
$phone = trim($_POST['phone']);
$frommail = "info@mydomain.co.za";
$subject = "Contact Form";
$message = "Were you injured in a car or taxi accident?: $Question1 \r\n Was it within the past 3 years?: $Question2 \r\n Did you have serious injuries?: $Question3 \r\n Were you in hospital because of the accident?: $Question4 \r\n How many days did you spend in hospital?: $Question5 \r\n Did you undergo surgery?: $Question6 \r\n Do you still suffer as a result of the accident?: $Question7 \r\n Email: $email \r\n Phone: $phone";
$headers = "From:" . $frommail;
$mailsent = mail($to, $subject, $message, $headers);
/**
}
} **/
?>