Tech Support Guy banner
Status
Not open for further replies.

help with contact form

Solved 
3K views 30 replies 3 participants last post by  JiminSA 
#1 ·
Hi, the following code is a functioning contact form with captcha; exactly what I want, that is if I could get it sent:
following that code isthe code for "send_form_email.php", (action=")
A OK until Clicking "send"; regardless if "comments" is filled, error code is displayed.
After a week of this and dozens of searches, ok I need help. thanks
=================================================================
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">



Contact Us

Please send your message below. We will get back to you at the earliest!
✔ means required





✔ Name

✔ Email

Comments/Questions

Enter Code >


===============================================================
<?php
if(isset($_POST['email'])) {

// CHANGE THE TWO LINES BELOW
$email_to = "charlzguitarz@gmail.com";

$email_subject = "charlzguitarz contact form";

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."

";
echo "Please go back and fix these errors.

";
die();
}

// validation expected data exists
if(!isset($_POST['name']) ||
!isset($_POST['email']) ||
!isset($_POST['comments'])))
{ died('there appears to be a problem with your submission.'); }

$name = $_POST['name']; // required
$email_from = $_POST['email']; // required
$comments = $_POST['comments']; // 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 .= 'is the Email Address you entered valid?
'; }
$string_exp = "/^[A-Za-z .'-]+$/";
if(!preg_match($string_exp,$name))
{ $error_message .= 'is the Name you entered valid?
'; }
if(strlen($comments) < 2)
{ $error_message .= 'The Comments you entered do not appear to be valid.
'; }
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($name)."\n";
$email_message .= "Email: ".clean_string($email_from)."\n";
$email_message .= "Comments/Questions: ".clean_string($comments)."\n";

// create email headers
$headers = 'From: '.$email_from."\r\n".
'Reply-To: '.$email_from."\r\n" .
'X-Mailer: PHP/' . phpversion();
@mail($email_to, $email_subject, $email_message, $headers);
?>

Thank you for contacting us. We will be in touch with you very soon.
<?php
}
die();
?>
 
See less See more
#2 · (Edited)
Try placing your function (died) at the very start of your php script instead of within the conditional clause - if(isset($_POST['email']))...
... also change @mail to mail.
@mail suppresses error messages (which you may want to see!)
 
#3 ·
=================================================
is this what you suggested? submission displays "; echo $error."....etc.,....etc.,...
--------------------------------------------------------------------------------
<?hp
if(isset($_POST['email'])) {

function died($error) {
// your error code can go here
echo "There were error(s) found with form you submitted. ";
echo "These errors appear below.

";
echo $error."

";
echo "Please go back and fix these errors.

";
die();
}

// validation expected data exists
if(!isset($_POST['name']) ||
!isset($_POST['email']) ||
!isset($_POST['comments'])))
{ died('problem with your submission.'); }

$name = $_POST['name']; // required
$email_from = $_POST['email']; // required
$comments = $_POST['comments']; // 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 .= 'is the Email Address you entered valid?
'; }
$string_exp = "/^[A-Za-z .'-]+$/";
if(!preg_match($string_exp,$name))
{ $error_message .= 'is the Name you entered valid?
'; }
if(strlen($comments) < 2)
{ $error_message .= 'The Comments you entered do not appear to be valid.
'; }
if(strlen($error_message) > 0)
{ died($error_message); }
$email_message = "Form details below.\n\n";

// CHANGE THE TWO LINES BELOW
$email_to = "charlzguitarz@gmail.com";

$email_subject = "charlzguitarz contact form";

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_from)."\n";
$email_message .= "Comments/Questions: ".clean_string($comments)."\n";

// create email headers
$headers = 'From: '.$email_from."\r\n".
'Reply-To: '.$email_from."\r\n" .
'X-Mailer: PHP/' . phpversion();
mail($email_to, $email_subject, $email_message, $headers);
?>

Thank you for contacting us. We will be in touch with you very soon.
<?php
}
die();
?>
 
#4 ·
PHP:
<?php
function died($error) {
// your error code can go here
echo "There were error(s) found with form you submitted. ";
echo "These errors appear below.

";
echo $error."

";
echo "Please go back and fix these errors.

";
die();
}

if(isset($_POST['email'])) {
 
#5 ·
-------------------------------------------------------------
this code doesn't throw error but doesn't send form
-----------------------------------------------------------
<?php
function died($error) {
// your error code can go here
echo "There were error(s) found with form you submitted. ";
echo "These errors appear below.

";
echo $error."

";
echo "Please go back and fix these errors.

";
die();
}

if(isset($_POST['email'])) {

// validation expected data exists
if(!isset($_POST['name']) ||
!isset($_POST['email']) ||
!isset($_POST['comments'])))
{ died('problem with your submission.'); }

$name = $_POST['name']; // required
$email_from = $_POST['email']; // required
$comments = $_POST['comments']; // 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 .= 'is the Email Address you entered valid?
'; }
$string_exp = "/^[A-Za-z .'-]+$/";
if(!preg_match($string_exp,$name))
{ $error_message .= 'is the Name you entered valid?
'; }
if(strlen($comments) < 2)
{ $error_message .= 'The Comments you entered do not appear to be valid.
'; }
if(strlen($error_message) > 0)
{ died($error_message); }
$email_message = "Form details below.\n\n";

// CHANGE THE TWO LINES BELOW
$email_to = "charlzguitarz@gmail.com";

$email_subject = "charlzguitarz contact form";

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_from)."\n";
$email_message .= "Comments/Questions: ".clean_string($comments)."\n";

// create email headers
$headers = 'From: '.$email_from."\r\n".
'Reply-To: '.$email_from."\r\n" .
'X-Mailer: PHP/' . phpversion();
mail($email_to, $email_subject, $email_message, $headers);
?>

Thank you for contacting us. We will be in touch with you very soon.
<?php
}
die();
?>
 
#7 · (Edited)
Please open a new thread for your next problem area - the Captcha (which does not work), because it is javascript and requires expertise I do not possess;)
But I do notice one problem ...
In order to perform javascript we must include a link to the js library in the section of our html ...
HTML:
the link was derived from here
 
#8 ·
Please open a new thread for your next problem area - the Captcha (which does not work), because it is javascript and requires expertise I do not possess;)
But I do notice one problem ...
In order to perform javascript we must include a link to the js library in the section of our html ...
HTML:
the link was derived from here
--------------------------------------------------------------
Thanks so much for your help , I have tried numerous versions attempting to send the form, none of them working. Never would have anticipated the difficulty. I went at it in stages, form, validation, captcha, then response. I use xammp. I'm copying and pasting your sugestions but falling short. Sending full code to ensure all is evident: The captcha does work.
------------------------------------------------------------------------

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">



CKguitarz contact page








Contact Us

Please send your message below. We will get back to you at the earliest!
✔ means required





✔ Name

✔ Email

Comments/Questions

!-- ****************************************************** -->

!-- ****************************************************** -->

Enter Code >


------------------------------------------------------------
<?php
function died($error) {
// your error code can go here
echo "There were error(s) found with form you submitted. ";
echo "These errors appear below.

";
echo $error."

";
echo "Please go back and fix these errors.

";
die(); }

if(isset($_POST['email'])) {


// validation expected data exists
if(!isset($_POST['name']) ||
!isset($_POST['email']) ||
!isset($_POST['comments']))
{ died('problem with your submission.'); }

$name = $_POST['name']; // required
$email_from = $_POST['email']; // required
$comments = $_POST['comments']; // 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 .= 'is the Email Address you entered valid?
'; }
$string_exp = "/^[A-Za-z .'-]+$/";
if(!preg_match($string_exp,$name))
{ $error_message .= 'is the Name you entered valid?
'; }
if(strlen($comments) < 2)
{ $error_message .= 'The Comments you entered do not appear to be valid.
'; }
if(strlen($error_message) > 0)
{ died($error_message); }
$email_message = "Form details below.\n\n";

// CHANGE THE TWO LINES BELOW
$email_to = "charlzguitarz@gmail.com";
$email_subject = "charlzguitarz contact form";

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_from)."\n";
$email_message .= "Comments/Questions: ".clean_string($comments)."\n";


// create email headers
$headers = 'From: '.$email_from."\r\n".
'Reply-To: '.$email_from."\r\n" .
'X-Mailer: PHP/' . phpversion();
mail($email_to, $email_subject, $email_message, $headers);
?>

Thank you for contacting us. We will be in touch with you very soon.
<?php
}
die();
?>
 
#11 ·
if((!isset($_POST['name']) || (isset($_POST['email'])) || (!isset($_POST['comments'])))
The extra set of brackets may make it more readable, Colin, but they are not needed - so long as there is at least one set of parentheses in a compound if statement, it will work;)
 
#12 ·
When you say the Captcha works, have you tried sending through no input or an incorrect number? When I submit with blank or incorrect input, the submission succeeds without any alertso_O
Sorry, but I cannot find where the function checkform is triggered:(
----------------------------------------------------------------------------
being current with your much appreciated suggestions:
When I leave name or email blank I get "please fill out this field"
When I fill out required fields and submit with blank code I get "security code should not be empty"
When I fill out required fields and submit with incorrect code I get "security code did not match"
when is filled out completely and correctly I get no errors and no delivery ?
-------------------------------------------------------------------------
html:




✔ Name

✔ Email

Comments/Questions
!-- ****************************************************** -->

!-- ****************************************************** -->

Enter Code >




----------------------------------------------------------------------
php:
if(isset($_POST['email'])) {


// validation expected data exists
if(!isset($_POST['name']) ||
!isset($_POST['email']) ||
!isset($_POST['comments']))
{ died('problem with your submission.'); }

$name = $_POST['name']; // required
$email_from = $_POST['email']; // required
$comments = $_POST['comments']; // 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 .= 'is the Email Address you entered valid?
'; }
$string_exp = "/^[A-Za-z .'-]+$/";
if(!preg_match($string_exp,$name))
{ $error_message .= 'is the Name you entered valid?
'; }
if(strlen($comments) < 2)
{ $error_message .= 'The Comments you entered do not appear to be valid.
'; }
if(strlen($error_message) > 0)
{ died($error_message); }
$email_message = "Form details below.\n\n";

// CHANGE THE TWO LINES BELOW
$email_to = "charlzguitarz@gmail.com";
$email_subject = "charlzguitarz contact form";

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_from)."\n";
$email_message .= "Comments/Questions: ".clean_string($comments)."\n";
 
#13 ·
I really appreciate your sticking w/me jiminSA.
I changed this:

with this:

with or without code the error php code is displayed:

"; echo $error."

"; echo "Please go back and fix these errors.

"; die(); } if(isset($_POST['email'])) { // validation expected data exists if(!isset($_POST['name']) || !isset($_POST['email']) || !isset($_POST['comments'])) { died('problem with your submission.'); } $name = $_POST['name']; // required $email_from = $_POST['email']; // required $comments = $_POST['comments']; // 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 .= 'is the Email Address you entered valid?
'; } $string_exp = "/^[A-Za-z .'-]+$/"; if(!preg_match($string_exp,$name)) { $error_message .= 'is the Name you entered valid?
'; } if(strlen($comments) < 2) { $error_message .= 'The Comments you entered do not appear to be valid.
'; } if(strlen($error_message) > 0) { died($error_message); } $email_message = "Form details below.\n\n"; // CHANGE THE TWO LINES BELOW $email_to = "charlzguitarz@gmail.com"; $email_subject = "charlzguitarz contact form"; 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_from)."\n"; $email_message .= "Comments/Questions: ".clean_string($comments)."\n"; // create email headers $headers = 'From: '.$email_from."\r\n". 'Reply-To: '.$email_from."\r\n" . 'X-Mailer: PHP/' . phpversion(); mail($email_to, $email_subject, $email_message, $headers); ?> Thank you for contacting us. We will be in touch with you very soon.
 
#14 · (Edited)
What I would like you to do is post the code you have for your html file and your php file, entirely and separately, using the Insert... facility which you can invoke by clicking the 4th icon from the right at the top of the reply box. This makes it much easier to read;) I am using the following code, which successfully sends the email, but which does not perform the Captcha check:
The HTML file:
HTML:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">

[B][CENTER]

[B][SIZE=14]Contact Us[/SIZE][/B]

Please send your message below. We will get back to you at the earliest! 
✔ means required





 ✔ Name

 ✔ Email

Comments/Questions

Enter Code >

[/CENTER]
The PHP code:
PHP:
<?php
function died($error) {
// your error code can go here
echo "There were error(s) found with form you submitted. ";
echo "These errors appear below.

";
echo $error."

";
echo "Please go back and fix these errors.

";
die();
}

if(isset($_POST['email'])) {

// validation expected data exists
if( !isset($_POST['name']) || !isset($_POST['email']) || !isset($_POST['comments']) )
{ died('problem with your submission.'); }

$name = $_POST['name']; // required
$email_from = $_POST['email']; // required
$comments = $_POST['comments']; // 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 .= 'is the Email Address you entered valid?
'; }
$string_exp = "/^[A-Za-z .'-]+$/";
if(!preg_match($string_exp,$name))
{ $error_message .= 'is the Name you entered valid?
'; }
if(strlen($comments) < 2)
{ $error_message .= 'The Comments you entered do not appear to be valid.
'; }
if(strlen($error_message) > 0)
{ died($error_message); }
$email_message = "Form details below.\n\n";

// CHANGE THE TWO LINES BELOW
$email_to = "charlzguitarz@gmail.com";

$email_subject = "charlzguitarz contact form";

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 .= "Email: ".clean_string($email_from)."
";
$email_message .= "Comments/Questions: ".clean_string($comments)."
";

// create email headers
$headers = 'From: '.$email_from."
".
'Reply-To: '.$email_from."
" .
'X-Mailer: PHP/' . phpversion();
//mail($email_to, $email_subject, $email_message, $headers);
echo $email_to."
".$email_subject."
".$email_message."
".$headers;
?>


Thank you for contacting us. We will be in touch with you very soon.
<?php
}
die();
?>
If we do a comparison, we should be able to sort both problems on both sides:)
FYI: You may notice that I have replaced the actual mailing with an echo of the email to be sent - this, because xampp does not d0 email send;)
 
#15 ·
What I would like you to do is post the code you have for your html file and your php file, entirely and separately, using the Insert... facility which you can invoke by clicking the 4th icon from the right at the top of the reply box. This makes it much easier to read;) I am using the following code, which successfully sends the email, but which does not perform the Captcha check
----------------------------------------------------------------------------------
1) post html code ?
2) click the 4th icon from right at the top of the reply box from your eply?
3) post php?
4) click the 4th icon from right at the top of the reply box from your reply?
-----------------------------------------------------------------------------------
 
#19 ·
onsubmit="return checkform(this);"
Seems to have been my problem, this side...
I replaced your " quotes, with the " character and now get Captcha working;)
As regards the php script, can you post a screen shot of the page which is produced after clicking submit? (Mine produces a mailing error message, which is because xampp doesn't handle emails - i.e. the mail would be sent successfully in an online hosting environment.)
 
#18 ·
php ode:
<?php
function died($error)
{
echo "There were error(s) found with form you submitted. ";
echo "These errors appear below.

";
echo $error."

";
echo "Please go back and fix these errors.

";
die();
}
if(isset($_POST['email'])) {

if(!isset($_POST['name']) ||
!isset($_POST['email']) ||
!isset($_POST['comments']))
{ died('problem with your submission.'); }

$name = $_POST['name'];
$email_from = $_POST['email'];
$comments = $_POST['comments'];

$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 .= 'is the Email Address you entered valid?
'; }
$string_exp = "/^[A-Za-z .'-]+$/";
if(!preg_match($string_exp,$name))
{ $error_message .= 'is the Name you entered valid?
'; }
if(strlen($comments) < 2)
{ $error_message .= 'The Comments you entered do not appear to be valid.
'; }
if(strlen($error_message) > 0)
{ died($error_message); }
$email_message = "Form details below.\n\n";

$email_to = "charlzguitarz@gmail.com";
$email_subject = "charlzguitarz contact form";

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_from)."\n";
$email_message .= "Comments/Questions: ".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);

}
die();
?>
 
#20 ·
Seems to have been my problem, this side...'m sorry, I don't understand.
I replaced your " quotes, with the " character and now get Captcha working;)'m sorry, I don't understand.
As regards the php script, can you post a screen shot of the page which is produced after clicking submit?
(Mine produces a mailing error message, which is because xampp doesn't handle emails - i.e. the mail would be sent successfully in an online hosting environment.)I'm sorry, I don't understand.
-----------------------------------------------------------------
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">



CKguitarz contact page








Contact Us

Please send your message below. We will get back to you at the earliest!
✔ means required





✔ Name

✔ Email

✔ Comments/Questions




Enter Code >





---------------------------------------------------------------------------
<?php
function died($error) {
// your error code can go here
echo "There were error(s) found with form you submitted. ";
echo "These errors appear below.

";
echo $error."

";
echo "Please go back and fix these errors.

";
die();
}

if(isset($_POST['email'])) {

// validation expected data exists
if( !isset($_POST['name']) || !isset($_POST['email']) || !isset($_POST['comments']) )
{ died('problem with your submission.'); }

$name = $_POST['name']; // required
$email_from = $_POST['email']; // required
$comments = $_POST['comments']; // 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 .= 'is the Email Address you entered valid?
'; }
$string_exp = "/^[A-Za-z .'-]+$/";
if(!preg_match($string_exp,$name))
{ $error_message .= 'is the Name you entered valid?
'; }
if(strlen($comments) < 2)
{ $error_message .= 'The Comments you entered do not appear to be valid.
'; }
if(strlen($error_message) > 0)
{ died($error_message); }
$email_message = "Form details below.\n\n";

// CHANGE THE TWO LINES BELOW
$email_to = "charlzguitarz@gmail.com";

$email_subject = "charlzguitarz contact form";

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 .= "Email: ".clean_string($email_from)."
";
$email_message .= "Comments/Questions: ".clean_string($comments)."
";

// create email headers
$headers = 'From: '.$email_from."
".
'Reply-To: '.$email_from."
" .
'X-Mailer: PHP/' . phpversion();
//mail($email_to, $email_subject, $email_message, $headers);
echo $email_to."
".$email_subject."
".$email_message."
".$headers;
?>


Thank you for contacting us. We will be in touch with you very soon.
<?php
}
die();
?>
------------------------------------------------------------------------------------
This came up on my screen upon submission: form wasn't sent
-----------------------------------------------------------------------------
Rectangle Font Operating system Circle Multimedia

charlzguitarz@gmail.com
charlzguitarz contact form
Form details below.
Name: itsme
Email: ckguitarz@gmail.com
Comments/Questions: I need to know what shipping cost is

From: ckguitarz@gmail.com
Reply-To: ckguitarz@gmail.com
X-Mailer: PHP/5.5.22
Thank you for contacting us. We will be in touch with you very soon.
 
#22 ·
I'm sorry, I don't understand.
Re the email: If you try to send an email in a xampp test environment you'll get a php mailer function error - which is what I thought was happening and you were thinking that the form wasn't being 'sent'. So I needed to see the screen you ended up with.
Re the Captcha: My browser was disregarding the onsubmit, because of the quote marks. When I changed them, the Captcha worked.
I just discovered that all my submissions today were in my spam folder addressed to the sender
Good;)
So, with that discovery, is there still a problem or is it resolved?
 
#23 ·
Charles, I used google and found that you have a comprehensive website up on the web - https://www.charlesguitars.co.uk/
So I guess you were experimenting(y) Whether you'll use what you have created or not, I feel duty bound to let you know that it's not a good idea to leave your user in limbo after contact has been established and it would be better to automatically return him/her to your main site after form submission.
With this in mind, would you like me to post some code to do this?;)
 
#24 ·
My site is https://www.charlesguitars.com
Here is latest html code:
---------------------------------------------------------------
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"

"http://www.w3.org/TR/html4/loose.dtd">



CKguitarz contact page










Contact Us

Please send your message below. We will get back to you at the earliest!
✔ means required





✔ Name

✔ Email

✔ Comments/Questions




Enter Code >






webmaster
copyright &copy 2000-2019
[privacy]
image of home

--------------------------------------------------------------
https://www.charlesguitars.co.uk/ - ?
I just ran https://www.charlesguitars.com/contact-me.html and upon submission the ollowing was displayed on my (the sender's screen?):
--------------------------------------------------------------------
charlzguitarz@gmail.com
charlzguitarz contact form
Form details below.
Name: Charlie Kirk
Email: ckguitarz@gmail.com
Comments/Questions: how much is shipping

From: ckguitarz@gmail.com
Reply-To: ckguitarz@gmail.com
X-Mailer: PHP/5.5.22
Thank you for contacting us. We will be in touch with you very soon.
------------------------------------------------------------------------------
I don't receive the form at my email
( charlzguitarz@gmail.com ).
-----------------------------------------------------------
I'm stymied, the last couple times I got no re result from submission.
 
#25 · (Edited)
Ah, so we still have a problem on the 'live" system ...
I really need to see the code for the php form handler - contact-me.php - but in the interrim you need to ensure that the changes we made to the test form handler (html_form_send.php) - reflect in the contact-me.php;)
(Also check your Spam folder - as if you haven't;))
 
#28 ·
following is the php code for "contact-me.php"; I just renamed "html_form_send.php".
I don't think I screwed that up.
<?php
function died($error) {
// your error code can go here
echo "There were error(s) found with form you submitted. ";
echo "These errors appear below.

";
echo $error."

";
echo "Please go back and fix these errors.

";
die();
}

if(isset($_POST['email'])) {

// validation expected data exists
if( !isset($_POST['name']) || !isset($_POST['email']) || !isset($_POST['comments']) )
{ died('problem with your submission.'); }

$name = $_POST['name']; // required
$email_from = $_POST['email']; // required
$comments = $_POST['comments']; // 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 .= 'is the Email Address you entered valid?
'; }
$string_exp = "/^[A-Za-z .'-]+$/";
if(!preg_match($string_exp,$name))
{ $error_message .= 'is the Name you entered valid?
'; }
if(strlen($comments) < 2)
{ $error_message .= 'The Comments you entered do not appear to be valid.
'; }
if(strlen($error_message) > 0)
{ died($error_message); }
$email_message = "Form details below.\n\n";

// CHANGE THE TWO LINES BELOW
$email_to = "charlzguitarz@gmail.com";
$email_subject = "charlzguitarz contact form";

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 .= "Email: ".clean_string($email_from)."
";
$email_message .= "Comments/Questions: ".clean_string($comments)."
";

// create email headers
$headers = 'From: '.$email_from."
".
'Reply-To: '.$email_from."
" .
'X-Mailer: PHP/' . phpversion();
//mail($email_to, $email_subject, $email_message, $headers);
echo $email_to."
".$email_subject."
".$email_message."
".$headers;
?>
-------------------------------------------------------------------------------
Are you 100% sure that your .com host handles emails? - My host is ipage. this is from chat with ipage rep:
" I have corrected session path for the PHP.ini file
Still there is some issue with the contact form.
I have taken an assistance from technical specialist since I have no access to back end of the server.
Technical specialist has informed that there is an issue with Script that has used in Contact form."
----------------------------------------------------------------------------
You saw the 2 changes/additions in the HTML? The ones at the bottom are in most o my pages. The "onunload was in response to your post. I've removed and reinserted these a couple of times.
 
#31 ·
any new ideas why no progress? I contacted another forum for answers and was admonished for contacting a second forum
Sorry but I have been offline for a couple of weeks for personal reasons:(
You say - "The onunload was in response to your post. I've removed and reinserted these a couple of times." - I never suggested onunload:confused: Why would you want to use it?
Just make sure that the 'action=' name in your form matches the php form handler's name and that all the changes I have suggested are in your html and php and you should be good to go;)
 
Status
Not open for further replies.
You have insufficient privileges to reply here.
Top