<?php
if(isset($_POST['txtEmail'])) {
// EDIT THE 2 LINES BELOW AS REQUIRED
$email_to = "xyz@abc.com";
$email_subject = "Subject";
$email_from = "abc@xyz.com";
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.";
echo $error."<br /><br />";
echo "Please go back and fix these errors.<br /><br />";
die();
}
// validation expected data exists
if(!isset($_POST['txtName']) ||
!isset($_POST['txtEmail']) ||
!isset($_POST['txtAddress']) ||
!isset($_POST['txtContact']) ||
!isset($_POST['txtUpload'])) {
died('We are sorry, but there appears to be a problem with the form you submitted.');
}
$name = $_POST['txtName']; // required
$email = $_POST['txtEmail']; // required
$address = $_POST['txtAddress']; // required
$contact = $_POST['txtContact']; // not required
$upload = $_POST['txtUpload']; // required
$email_message = "Form Details are below.\n\n";
function clean_string($string) {
$bad = array("content-type","bcc:","to:","cc:","href");
return str_replace($bad,"",$string);
}
$email_message .= "Full Name: ".clean_string($name)."\n\n";
$email_message .= "Address: ".clean_string($address)."\n\n";
$email_message .= "Email ID: ".clean_string($email)."\n\n";
$email_message .= "Contact No.: ".clean_string($contact)."\n\n";
$email_message .= "File: ".clean_string($upload)."\n\n";
// create email headers
$headers = 'From: '.$email_from."\r\n".
'Reply-To: '.$email."\r\n" .
'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.
<?php
}
?>
i am a rookie in php
I got 2 problems
1) I am not able to insert a code for file upload in the above code.
2) In other type of form (with different textfields).i have a text (it is like a disclaimer) in the html form which i want it in email too.