Hi
Im new to PHP coding so please goes easy if i've done it all wrong.
When ever i hit the submit button it just opens a new page.
My page is hosted by Fasthost and they have a few requirements for the PHP code used on their servers.
one is the "-f" in the $sent = mail($email_to, $email_subject, $message, $headers, "-f" . $email_from) line the other is $email_from=$_POST["email"].
My form code:
<form id="form1" name="form1" method="post" action="form/sendmail.php">
<table width="100%" border="0" cellspacing="0" cellpadding="3">
<tr>
<td width="38%"><label>
<div align="right">Name</div>
</label></td>
<td width="62%"><input name="Name" type="text" id="Name" tabindex="1" size="50" /></td>
</tr>
<tr>
<td><label>
<div align="right">Address</div>
</label></td>
<td><textarea name="Address" cols="50" id="Address" tabindex="2"></textarea></td>
</tr>
<tr>
<td><label>
<div align="right">Postcode</div>
</label></td>
<td><input name="Postcode" type="text" id="Postcode" tabindex="3" /></td>
</tr>
<tr>
<td><label>
<div align="right">Email</div>
</label></td>
<td><input name="Email" type="text" id="Email" tabindex="4" size="50" /></td>
</tr>
<tr>
<td><label>
<div align="right">Gender</div>
</label></td>
<td><select name="Gender" size="1" id="Gender" tabindex="5">
<option value="1">Male</option>
<option value="2">Female</option>
<option value="0" selected="selected">Please Select</option>
</select></td>
</tr>
<tr>
<td><label>
<div align="right">Age</div>
</label></td>
<td><select name="Age" size="1" id="Age">
<option value="0">Please Select</option>
<option value="1"><16</option>
<option value="2">17-20</option>
<option value="3">21-25</option>
<option value="4">26-30</option>
<option value="5">31-35</option>
<option value="6">36-40</option>
<option value="7">41-45</option>
<option value="8">46-50</option>
<option value="9">50></option>
</select></td>
</tr>
<tr>
<td><label>
<div align="right">Would you prefer any further correspondence to be in Welsh Or English </div>
</label></td>
<td><select name="Correspondence" size="1" id="Correspondence">
<option value="0">Please Select</option>
<option value="1">Welsh</option>
<option value="2">English</option>
</select>
<label>
<input type="submit" name="Submit" value="Submit" />
<input name="Reset" type="reset" id="Reset" value="Reset" />
</label></td>
</tr>
</table>
</form>
My PHP code:
<?php
$email_to="form@iter-research.co.uk";
$name=$_POST["name"];
$email_from=$_POST["email"];
$message=$_POST["name,Address,Postcode,Email,Gender,Age,Correspondence"];
$email_subject="Consultation Form";
$headers=
"from:$email_from.\n";
"reply-to:$email_from.\n";
if(!filter_var($email_from, FILTER_VALIDATE_EMAIL)) {
die("The email address entered is invalid.");
$message = "Name: ". $name . "\r\nMessage: " . $message;
ini_set("sendmail_from", $email_from);
$sent = mail($email_to, $email_subject, $message, $headers, "-f" . $email_from);
if($sent) {
header("Location: " . http://www.iter-rese...hank_you.html);
} else {
echo "There has been an error sending your message. Please try later.";
}
?>
What am i doing wrong??
Many thanks Simon
The form is on the get_involved page
Iter-research