Morning All, This is driving me mad but I'm pretty sure someone who knows what they are doing will spot the mistake easily. I can handle HTML and CSS but JS & PHP elude me..
PHP / JS help please..
6
Morning All,
This is driving me mad but I'm pretty sure someone who knows what they are doing will spot the mistake easily. I can handle HTML and CSS but JS & PHP elude me..
I have downloaded a template CSS website which has a contact form on it that I cannot get working..
The contact page is here - Fencing Essex
Then I found out I needed a PHP page to handle the request to get it to email to me. So I downloaded and adjusted this -
<?php
if(isset($_POST['email'])) {
// EDIT THE 2 LINES BELOW AS REQUIRED
$email_to = "sales@collinsonfencing.com";
$email_subject = "Your email subject line";
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['author']) ||
!isset($_POST['email']) ||
!isset($_POST['text'])) {
died('We are sorry, but there appears to be a problem with the form you submitted.');
}
$author = $_POST['author']; // required
$email_from = $_POST['email']; // required
$text = $_POST['text']; // required
$error_message = "";
$email_exp = '/^[A-Za-z0-9._%-]+@[A-Za-z0-9.-]+\.[A-Za-z]{2,4}$/';
if(!preg_match($email_exp,$email_from)) {
$error_message .= 'The Email Address you entered does not appear to be valid.<br />';
}
$string_exp = "/^[A-Za-z .'-]+$/";
if(!preg_match($string_exp,$author)) {
$error_message .= 'The Name you entered does not appear to be valid.<br />';
}
if(strlen($text) < 2) {
$error_message .= 'The Message you entered do 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 .= "Name: ".clean_string($author)."\n";
$email_message .= "Email: ".clean_string($email)."\n";
$email_message .= "Comments: ".clean_string($text)."\n";
// create email headers
$headers = 'From: '.$email."\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
}
?>
If I go onto it and send a message I get the success html page but no email appears in my inbox....
Any ideas please??
Cheers
Steve
This is driving me mad but I'm pretty sure someone who knows what they are doing will spot the mistake easily. I can handle HTML and CSS but JS & PHP elude me..
I have downloaded a template CSS website which has a contact form on it that I cannot get working..
The contact page is here - Fencing Essex
Then I found out I needed a PHP page to handle the request to get it to email to me. So I downloaded and adjusted this -
<?php
if(isset($_POST['email'])) {
// EDIT THE 2 LINES BELOW AS REQUIRED
$email_to = "sales@collinsonfencing.com";
$email_subject = "Your email subject line";
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['author']) ||
!isset($_POST['email']) ||
!isset($_POST['text'])) {
died('We are sorry, but there appears to be a problem with the form you submitted.');
}
$author = $_POST['author']; // required
$email_from = $_POST['email']; // required
$text = $_POST['text']; // required
$error_message = "";
$email_exp = '/^[A-Za-z0-9._%-]+@[A-Za-z0-9.-]+\.[A-Za-z]{2,4}$/';
if(!preg_match($email_exp,$email_from)) {
$error_message .= 'The Email Address you entered does not appear to be valid.<br />';
}
$string_exp = "/^[A-Za-z .'-]+$/";
if(!preg_match($string_exp,$author)) {
$error_message .= 'The Name you entered does not appear to be valid.<br />';
}
if(strlen($text) < 2) {
$error_message .= 'The Message you entered do 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 .= "Name: ".clean_string($author)."\n";
$email_message .= "Email: ".clean_string($email)."\n";
$email_message .= "Comments: ".clean_string($text)."\n";
// create email headers
$headers = 'From: '.$email."\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
}
?>
If I go onto it and send a message I get the success html page but no email appears in my inbox....
Any ideas please??
Cheers
Steve
- eluminoustechnologies
- [ 1 ] Thanks
- [1] reply
- Steve2129
- [1] reply
Next Topics on Trending Feed
-
6