Hi.
Iam trying to sent this form values to my email
Its not working
Can anyone help to solve this…
This is my form
<form method="POST" action="sendemail.php">
<table width="450px">
<tr>
<td valign="top">
<label for="name">Name </label>
</td>
<td valign="top">
<input type="text" name="name" maxlength="50" size="30">
</td>
</tr>
<tr>
<td valign="top">
<label for="organisation">Organisation </label>
</td>
<td valign="top">
<input type="text" name="organisation" maxlength="50" size="30">
</td>
</tr>
<tr>
<td valign="top">
<label for="contact">Contact no </label>
</td>
<td valign="top">
<input type="text" name="contact" maxlength="80" size="30">
</td>
</tr>
<tr>
<td valign="top">
<label for="remarks">Remarks</label>
</td>
<td valign="top">
<textarea name="remarks" maxlength="50" ></textarea>
</td>
</tr>
<tr>
<td valign="top">
<label for="designation">Designation </label>
</td>
<td valign="top">
<input type="text" name="designation" maxlength="50" size="50">
</td>
</tr>
<tr>
<td valign="top">
<label for="email">E-mail </label>
</td>
<td valign="top">
<input type="text" name="email" maxlength="50" size="40">
</td>
</tr>
<tr>
<td colspan="2" style="text-align:center">
<input type="submit" value="Submit"> <input type="reset" value="Reset">
</td>
</tr>
</table>
</form>
this is sendemail.php
<?php
session_start();
if(isset($_POST['email'])) {
// EDIT THE 2 LINES BELOW AS REQUIRED
$email_to = "-----------------l@gmail.com";
$email_subject = "Contact Details";
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['name']) ||
!isset($_POST['organisation']) ||
!isset($_POST['email']) ||
!isset($_POST['contact']) ||
!isset($_POST['designation']) ||
!isset($_POST['remarks'])) {
died('We are sorry, but there appears to be a problem with the form you submitted.');
}
$name = $_POST['name'];
$organisation = $_POST['organisation'];
$email = $_POST['email'];
$contact = $_POST['contact'];
$designation = $_POST['designation'];
$remarks = $_POST['remarks'];
$error_message = "";
$email_exp = '/^[A-Za-z0-9._%-]+@[A-Za-z0-9.-]+\\.[A-Za-z]{2,4}$/';
if(!preg_match($email_exp,$email)) {
$error_message .= 'The Email Address you entered does not appear to be valid.<br />';
}
$string_exp = "/^[A-Za-z .'-]+$/";
if(!preg_match($string_exp,$name)) {
$error_message .= 'Name you entered does not appear to be valid.<br />';
}
if(strlen($remarks) < 2) {
$error_message .= 'The Remarks you entered do not appear to be valid.<br />';
}
if(strlen($error_message) > 0) {
died($error_message);
}
$email_message = "Form details below.\
\
";
function clean_string($string) {
$bad = array("content-type","bcc:","to:","cc:","href");
return str_replace($bad,"",$string);
}
$email_message .= "Name: ".clean_string($name)."\
";
$email_message .= "Organisation: ".clean_string($organisation)."\
";
$email_message .= "Contact No: ".clean_string($contact)."\
";
$email_message .= "Email: ".clean_string($email)."\
";
$email_message .= "Remarks: ".clean_string($remarks)."\
";
$email_message .= "Designation: ".clean_string($designation)."\
";
$headers = 'From: '.$email."\\r\
".
'Reply-To: '.$email."\\r\
" .
'X-Mailer: PHP/' . phpversion();
@mail($email_to, $email_subject, $email_message, $headers);
}?>
<!-- include your own success html here -->
Thank you for contacting us. We will be in touch with you very soon.