I am working on a contact page that contains a contact form that goes to a .php page. For some reason, I am getting that my main host cannot handle this request.
The page is http://georgem.x10host.com/capstone/contact.html
The code for the PHP page is:
<?php
if(isset($_POST['email'])){
// Here is the email to information
$email_to = "meehangeorge73@gmail.com";
$email_subject = "This is from your website contact form";
$email_from = "CareerLink of Lancaster County";
// Error Code
function died($error){
echo "We are sorry, but there are error(s) found with the form you submitted.";
echo "These error(s) appear below.<br /><br />";
echo $error. "<br /><br />";
echo "Please go back and fix these errors <br />";
die();
}
// Validation
if(!isset(_POST['name']) ||
!isset(_POST['email']) ||
!isset(_POST['subject']) ||
!isset(_POST['message'])){
died('We are sorry but there appears to be a problem with the form you submitted.');
}
// Variables
$name = $_POST['name'];
$email = $_POST['email'];
$subject = $_POST['subject'];
$message = $_POST['message'];
// Expected Strings
$error_message ="";
$email_expect = '/^[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 .= 'The Name you entered does not appear to be valid.<br />';
}
$$string_expt = "/^[A-Za-z0-9.'-]+$/";
if(!preg_match($string_expt, $subject)){
$error_message .= 'The Subject you entered does not appear to be valid.<br />';
}
if(strlen($message)<2){
$error_message .= 'The message you entered does not appear to be valid.<br />';
}
if(strlen($error_message)>0){
died($error_message);
}
$error_message = "Form Details Below.\n\n";
// Sanitization
function clean_string($string){
$bad = array("content-type", "bcc", "to:", "cc:", "href");
return str_replace($bad, "", $string);
}
$email_message .= "Name:" . clean_string($name) . "\n";
$email_message .= "Email:" . clean_string($email) . "\n";
$email_message .= "Subject:" . clean_string($subject) . "\n";
$email_message .= "Message:" . clean_string($message) . "\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);
?>
<!-- Success Message Goes Here -->
Thank you for contacting us. We will be in touch with you shortly.<br />
Please cleck<a href="index.html">here</a> to go back to the home page.
<?php
}
?>
Any ideas what I am doing wrong will be greatly appreciated.
The page is http://georgem.x10host.com/capstone/contact.html
The code for the PHP page is:
<?php
if(isset($_POST['email'])){
// Here is the email to information
$email_to = "meehangeorge73@gmail.com";
$email_subject = "This is from your website contact form";
$email_from = "CareerLink of Lancaster County";
// Error Code
function died($error){
echo "We are sorry, but there are error(s) found with the form you submitted.";
echo "These error(s) appear below.<br /><br />";
echo $error. "<br /><br />";
echo "Please go back and fix these errors <br />";
die();
}
// Validation
if(!isset(_POST['name']) ||
!isset(_POST['email']) ||
!isset(_POST['subject']) ||
!isset(_POST['message'])){
died('We are sorry but there appears to be a problem with the form you submitted.');
}
// Variables
$name = $_POST['name'];
$email = $_POST['email'];
$subject = $_POST['subject'];
$message = $_POST['message'];
// Expected Strings
$error_message ="";
$email_expect = '/^[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 .= 'The Name you entered does not appear to be valid.<br />';
}
$$string_expt = "/^[A-Za-z0-9.'-]+$/";
if(!preg_match($string_expt, $subject)){
$error_message .= 'The Subject you entered does not appear to be valid.<br />';
}
if(strlen($message)<2){
$error_message .= 'The message you entered does not appear to be valid.<br />';
}
if(strlen($error_message)>0){
died($error_message);
}
$error_message = "Form Details Below.\n\n";
// Sanitization
function clean_string($string){
$bad = array("content-type", "bcc", "to:", "cc:", "href");
return str_replace($bad, "", $string);
}
$email_message .= "Name:" . clean_string($name) . "\n";
$email_message .= "Email:" . clean_string($email) . "\n";
$email_message .= "Subject:" . clean_string($subject) . "\n";
$email_message .= "Message:" . clean_string($message) . "\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);
?>
<!-- Success Message Goes Here -->
Thank you for contacting us. We will be in touch with you shortly.<br />
Please cleck<a href="index.html">here</a> to go back to the home page.
<?php
}
?>
Any ideas what I am doing wrong will be greatly appreciated.