I have tried to get my php scrip to work but it doesn't. can someone maybe help me to get it working please. Here is my script:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Untitled Document</title>
</head>
<?php
if(isset($_POST['mail'])) {
$email_to = "mymail@domain.com";
$email_subject = "email subject line";
function died($error)
{
echo "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();
}
if(!isset($_POST['Title']) ||
!isset($_POST['Name']) ||
!isset($_POST['Surname']) ||
!isset($_POST['Company']) ||
!isset($_POST['Email']) ||
!isset($_POST['ConfirmEmail']) ||
!isset($_POST['Tel']) ||
!isset($_POST['Fax']) ||
!isset($_POST['Comments']))
{
died('We are sorry, but there appears to be a problem with the form your submitted.');
}
$Title = $_POST['Title']; // required
$Name = $_POST['Name']; // required
$Surname = $_POST['Surname']; // required
$Company = $_POST['Company']; // not required
$Email = $_POST['Email']; // required
$ConfirmEmail = $_POST['ConfirmEmail']; // required
$Tel = $_POST['Tel']; // required
$Fax = $_POST['Fax']; // not required
$Comments = $_POST['Comments']; // required
$error_message = "error";
$email_exp = "^[A-Z0-9._%-]+@[A-Z0-9.-]+\.[A-Z]{2,4}$";
if(!eregi($email_exp,$email_from)) {
$error_message .= 'The Email Address you entered does not appear to be valid.<br />';
}
$string_exp = "^[a-z .'-]+$";
if(!eregi($string_exp,$Title)) {
$error_message .= 'The Title you entered does not appear to be valid.<br />';
}
if(!eregi($string_exp,$Name)) {
$error_message .= 'The Name you entered does not appear to be valid.<br />';
}
if(!eregi($string_exp,$Surname)) {
$error_message .= 'The Surname you entered does not appear to be valid.<br />';
}
if(!eregi($string_exp,$Company)) {
$error_message .= 'The Company you entered does not appear to be valid.<br />';
}
if(strlen(Ccomments) < 2) {
$error_message .= 'The Comments you entered do not appear to be valid.<br />';
}
$string_exp = "^[0-9 .-]+$";
if(!eregi($string_exp,$Tel)) {
$error_message .= 'The Telphone Number you entered does not appear to be valid.<br />';
}
$string_exp = "^[0-9 .-]+$";
if(!eregi($string_exp,$Fax)) {
$error_message .= 'The Telphone Number you entered does not appear to be valid.<br />';
}
if(strlen($error_message) > 0) {
died($error_message);
}
$email_message = "Form details below.\n\n";
function clean_string($string) {
$bad = array("content-type","bcc:","to:","cc:","href");
return str_replace($bad,"",$string);
}
$email_message .= "Title: ".clean_string($Title)."\n";
$email_message .= "Name: ".clean_string($Name)."\n";
$email_message .= "Surname: ".clean_string($Surname)."\n";
$email_message .= "Company: ".clean_string($Company)."\n";
$email_message .= "Email: ".clean_string($Email)."\n";
$email_message .= "Confirm Email: ".clean_string($ConfirmEmail)."\n";
$email_message .= "Tel: ".clean_string($Tel)."\n";
$email_message .= "Fax: ".clean_string($Fax)."\n";
$email_message .= "Comments: ".clean_string($Comments)."\n";
$headers = 'From: '.$email_from."\r\n".
'Reply-To: '.$email_from."\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.
<?
}
?>
<body>
</body>
</html>