Please let me know if this is not appropriate for CSS-Tricks.
I have 2 PHP forms on my website, the results for each form are to be e-mailed. Upon submit, on both forms, I get the message that the requests have been e-mailed successfully, and actually get the email. The trouble is, the emails are empty.
I guess it is safe to assume that the form.php files are located correctly on the server(?) They aren't in any special place,but residing in my root folder and identified by the server as being "application/x-httpd-php" files.
I haven't configured any "mail-handler" application. The server supports cgimail and has it installed I thought I had better stay with the php script because it seems to "halfway" work. Where do I go from here to resolve my dilemma?
Here is what I'm looking at, no _GET anywhere, I expanded on what I needed in my form after watching a video tutorial...... The following is from the smaller files that captures input from a simple email form.
$success = mail ( $webMaster, $emailSubject, $body, $headers ) ;
I'm using "mail" because it is what was used in the tutorial, and have been in search of clearing this up for a couple of hours .. to no avail. I'm assuming, unless there is something glaring that I should be embarrassed about, this 'mail' string might be the culprit?
Thanks for your reply, and willingness to help me out.
I commented out the line in question, no e-mail is send at all. As stevendeeds suggested, am I omitting _GET somewhere? I admit I am lost here, but am keeping a stiff upper lip about it. :-) I've looked at other examples, and have seen no reference to _GET (?)
I use a form myself that works perfectly but the code is a bit different from yours. Seems to work pretty well. Used it on a few occasions. The way I do it is have the form on a page say contact.php and have the form send to sendemail.php. This is the script inside sendemail.php. Obviously you can modify it and include the rest of your site design around it.
if(!$email == "" && (!strstr($email,"@") || !strstr($email,"."))) { echo "<h3>Please enter a valid email address in the format: user@domain.com</h3>\n"; $badinput = "<h3>Your query has not been sumbitted.</h3>\n"; echo $badinput; die ("Press back on your browser and try again."); }
if(empty($name) || empty($email) || empty($message )) { echo "<h2>You did not enter information in all the fields.</h2>\n"; die ("<h2>Press back on your browser and try again.</h2>"); }
Thanks AWKM, I appreciate your tenacity in trying to help me solve this problem. Let me check it out. I'm not concerned with the differences in code at this point, if it works for you, I'm willing to give it a try.
In my searching for a solution I have run across many people with the same problem as I have. The video tutorial was a popular tutvids tutorial, that seemingly drew a large crowd. I'm actually surprised, his videos are generally spot on.
I don't know, not having too much luck with the coding you provided above AWKM. I fail to get a returned e-mail, I will toy around with it further. Naturally, I had to modify it for the values I have in my form, etc.
I'm thinking, I'm not married to php in getting something suitable to bring form data into an e-mail. I may have ta abandon php, and look for alternatives. Cgi-email I believe can do the same thing, minus the php scripting. I thought, since I am also working on a WP blog for my site, the continued exposure to php would aid me in learning more about php.
If anyone has $.02 they would like to share, I'm open. If I need to, I can share my actual html forms ................ I find it difficult to believe that with all this talent on the forums, someone hasn't stepped forward with a "tried and true work-around. ;-)
I would start by commenting out the part that sends the email and just echoing out all of your variables from the form.
Heres a very stripped down version of an email sent in PHP.
Hope this helps to get you on the right track.
<? // Variables from form. Im not really using these anywhere in the email below. I just set them as an example. $email = $_POST['email']; $firstname = $_POST['firstname']; $lastname = $_POST['lastname']; $password = sha1($_POST['password']); $city = $_POST['city']; $state = $_POST['state']; // subject $subject = 'Thanks for signing up!';
// HTML message $message = ' <html> <head> <title>' . $_POST['firstname'] . ' signed up for RYFO.</title> </head> <body> <p style="font-size: 19px;">' . $_POST['firstname'] . ',</p> <p style="font-size: 19px;"> Thanks for signing up.</p> <p style="font-size: 19px;">Your login credentials are </p> <p style="font-size: 19px;"> Username: ' . $_POST['email'] . '<br />Password: ' . $_POST['password'] . '</p> <p style="font-size: 19px;"> We hope to see you around the community.</p> </body> </html> ';
// To send HTML mail, the Content-type header must be set $headers = 'MIME-Version: 1.0' . "\r\n"; $headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";
I'd like to see your HTML just to see the naming. It may be that simple. I've looked over code for hours before and found that I'd named something wrong.
mail($to, $subject, $message, $headers); //Send them back to the form page with a success message. // From here is the html to the success page after e-mail was $theResults = <<< EOD
I don't mean to highjack your time, get back to me as you are able ....
I corrected the lack of closing php, no change. I guess there is only a finite number of ways I can toy with this, so as your able give it a second look.
// HTML message $message = ' <html> <head> <title>' . $email . ' sent you a message.</title> </head> <body> <p style="font-size: 19px;">' . $email. '</p> <p style="font-size: 19px;"> '. $questions .'</p> </body> </html> ';
// To send HTML mail, the Content-type header must be set $headers = 'MIME-Version: 1.0' . "\r\n"; $headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";
// Additional headers $headers .= 'To: <' . $_POST['email'] . '>' . "\r\n"; $headers .= 'From: My Web Site <justaguy@mywebsite.com>' . "\r\n";
// Mail it mail($to, $subject, $message, $headers); //Send them back to the form page with a success message. // From here is the html to the success page after e-mail was $theResults = <<< EOD ?> <html> <head> <meta http-equiv="Content-Type" content="text/html;charset=utf-8" /> <title>My Web Site/contact</title> <link href="main.css" rel="stylesheet" type="text/css" /> </head>
<body>
<div id="page-wrap" class="group">
<div id="header">
<div id="logo"></div>
<h1>My Web Site</h1>
<p>Yada yada</p>
</div><!--END of header-->
<div id="main-content">
<div id="results"> <p>Your request for additional information has successfully been forwarded.</p> <p>Thank you for your interest in My Web Site.</p> <p> You can expect a prompt response.</p>
The working code you posted does bring us to the "success" page, without an e-mail being sent. I have changed the opening php tag to include "php". I'm not certain what the string :
$headers = 'MIME-Version: 1.0' . "\r\n";
does, but I am by far behind you in knowledge.
Are we certain that we needed to amend the ENCTYPE in the html? I'm just asking ..... again, I trust your knowledge over the lack of mine. I am just thinking about the changes that have been introduced and noting the deficiencies (now) compared to the code and symptoms we had in the beginning.
"new code" ---> no email sent, uncertain if data is being captured, and failure of "success" page being rendered (I see that a "success" page is rendered here : http://dev.wovenland.com/justaguy/) but can't understand why it is failing on the site.
It has to be something quite simple (and evasive) at this point.
I have been plugging an alternate (working) email address of mine into the form on the web page itself, and typing gibberish, then hitting the "send" button. As part of the script you've put together, the sender (from my web page) receives an e-mail to their e-mail address after completing the form.
This is occurring, the "sender" will receive an email to their inbox and the question they type in the form is remitted to them. The "sender's" email address is formatted as a link that when clicked opens (in this case) a response through gmail.
Before I try the above, this may be helpful, or not, in the form, on the website, I plug in my website e-mail address as "sender" and type gibberish, and no email sent to my web site email address.
// HTML message $message = ' <html> <head> <title>' . $email . ' sent you a message.</title> </head> <body> <p style="font-size: 19px;">' . $email. '</p> <p style="font-size: 19px;"> '. $questions .'</p> </body> </html> ';
// To send HTML mail, the Content-type header must be set $headers = 'MIME-Version: 1.0' . "\r\n"; $headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";
// Additional headers. FILL IN YOUR EMAIL HERE $headers .= 'To: youremail@email.com' . "\r\n"; $headers .= 'From: My Web Site <justaguy@mywebsite.com>' . "\r\n"; $headers .= 'Reply-To: <' . $_POST['email'] . '>' . "\r\n"; // Mail it mail($to, $subject, $message, $headers); //Send them back to the form page with a success message. // From here is the html to the success page after e-mail was $theResults = <<< EOD ?> <html> <head> <meta http-equiv="Content-Type" content="text/html;charset=utf-8" /> <title>My Web Site/contact</title> <link href="main.css" rel="stylesheet" type="text/css" /> </head>
<body>
<div id="page-wrap" class="group">
<div id="header">
<div id="logo"></div>
<h1>My Web Site</h1>
<p>Yada yada</p>
</div><!--END of header-->
<div id="main-content">
<div id="results"> <p>Your request for additional information has successfully been forwarded.</p> <p>Thank you for your interest in My Web Site.</p> <p> You can expect a prompt response.</p>
Geez! I tried the latest send.php and failed receiving any e-mails, after plugging in all my site/email info into place. Actually I tried a couple of times.
Then I thought, well, I would go back and use the send.php that worked last, the one prior to the last one you submitted. No e-mail.! After making the changes to the "additional headers" and double checking my html.
(what the hell, checkout my site here: nearnorthwebdesign.com
1. contactFormprocess.php does not exist on your server. I get a 404 page when i click submit.
2. your enctype="text/plain" will not submit anything to your php file.
Delete your enctype="text/plain". You dont need it at all. Create contactFormprocess.php on your server and insert the latest send.php code I'm including here.
// HTML message $message = ' <html> <head> <title>' . $email . ' sent you a message.</title> </head> <body> <p style="font-size: 19px;">' . $email. '</p> <p style="font-size: 19px;"> '. $questions .'</p> </body> </html> ';
// To send HTML mail, the Content-type header must be set $headers = 'MIME-Version: 1.0' . "\r\n"; $headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";
// Additional headers. FILL IN YOUR EMAIL HERE $headers .= 'To: youremail@email.com' . "\r\n"; $headers .= 'From: My Web Site <justaguy@mywebsite.com>' . "\r\n"; $headers .= 'Reply-To: <' . $_POST['email'] . '>' . "\r\n"; // Mail it mail($to, $subject, $message, $headers); //Send them back to the form page with a success message. // From here is the html to the success page after e-mail was $theResults = <<< EOD ?> <html> <head> <meta http-equiv="Content-Type" content="text/html;charset=utf-8" /> <title>My Web Site/contact</title> <link href="main.css" rel="stylesheet" type="text/css" /> </head>
<body>
<div id="page-wrap" class="group">
<div id="header">
<div id="logo"></div>
<h1>My Web Site</h1>
<p>Yada yada</p>
</div><!--END of header-->
<div id="main-content">
<div id="results"> <p>Your request for additional information has successfully been forwarded.</p> <p>Thank you for your interest in My Web Site.</p> <p> You can expect a prompt response.</p>
Really? I know it's not an important issue, but really it actually is. Your code needs to be logical and written properly, using BR tags for spacing is bad coding practise. You should only be using CSS for styling!
@Brightonmike Yeah. I didnt make that, but BR tags are allowed to be used. I would have done it after the closing label tab, but I do definitely think you could use CSS to do this instead.
1. contactFormprocess.php does not exist on your server. I get a 404 page when i click submit. "quoteFormprocess.php" exists because that is my (current, soon to be replaced) attempt at processing the quote form on my quote page.
Response: contactFormprocess.php isn't being referenced to in my html any longer. That was the name/file for my "old" .php processing. Since working with you I am now simply adopting the send.php name/file to keep from getting (too) confused. I don't see that it is found on the server atm (?)
2. your enctype="text/plain" will not submit anything to your php file.
Response: The enctype for the send.php is "multipart/form-data". I just corrected the "case" of the text to lower case, it was all caps just now.
I don't understand, the issues you are raising here I can't see on the server, unless the number of changes that we've been going through are not being promptly updated on the server, but that's not making sense if you are "seeing" it and I am not (?)
I have 2 PHP forms on my website, the results for each form are to be e-mailed. Upon submit, on both forms, I get the message that the requests have been e-mailed successfully, and actually get the email. The trouble is, the emails are empty.
I guess it is safe to assume that the form.php files are located correctly on the server(?) They aren't in any special place,but residing in my root folder and identified by the server as being "application/x-httpd-php" files.
I haven't configured any "mail-handler" application. The server supports cgimail and has it installed I thought I had better stay with the php script because it seems to "halfway" work. Where do I go from here to resolve my dilemma?
$success = mail ( $webMaster, $emailSubject, $body, $headers ) ;
I'm using "mail" because it is what was used in the tutorial, and have been in search of clearing this up for a couple of hours .. to no avail. I'm assuming, unless there is something glaring that I should be embarrassed about, this 'mail' string might be the culprit?
I commented out the line in question, no e-mail is send at all. As stevendeeds suggested, am I omitting _GET somewhere? I admit I am lost here, but am keeping a stiff upper lip about it. :-) I've looked at other examples, and have seen no reference to _GET (?)
In my searching for a solution I have run across many people with the same problem as I have. The video tutorial was a popular tutvids tutorial, that seemingly drew a large crowd. I'm actually surprised, his videos are generally spot on.
I'll be back to report! Thanks again!
I'm thinking, I'm not married to php in getting something suitable to bring form data into an e-mail. I may have ta abandon php, and look for alternatives. Cgi-email I believe can do the same thing, minus the php scripting. I thought, since I am also working on a WP blog for my site, the continued exposure to php would aid me in learning more about php.
If anyone has $.02 they would like to share, I'm open. If I need to, I can share my actual html forms ................ I find it difficult to believe that with all this talent on the forums, someone hasn't stepped forward with a "tried and true work-around. ;-)
This saga will continue ....
Heres a very stripped down version of an email sent in PHP.
Hope this helps to get you on the right track.
Ah, how do I post HTML without having the coding stripped away?
http://pastebin.com/3wtqQxJm
This is the smaller of the two forms I've employed.
Sorry for the mess I've made of the coding, looks pretty embarrassing in pastebin
http://dev.wovenland.com/justaguy/
PS. I'm not capturing any of the entered data. I promise.
Pastebin link
This line in your HTML form should have the "multipart/form-data" as the ENCTYPE
Thanks, I'll report back ............
Here's is how I modified it, more than likely it me, but I am getting a 404 error, and no email sent from site to my mailbox.
http://pastebin.com/L8KnyCVF
copy/paste new enctype in form html
$subject line string
Sheaders .= 'From: My Site ' . "r/n/;
and then everything below that, which is success page html
Previously I was getting the success page in addition to a "no data capture e-mail"
I corrected the lack of closing php, no change. I guess there is only a finite number of ways I can toy with this, so as your able give it a second look.
Thanks d
Check this out. http://dev.wovenland.com/justaguy/
thats your code working. lemme get the code i have for ya.
$headers = 'MIME-Version: 1.0' . "\r\n";
does, but I am by far behind you in knowledge.
Are we certain that we needed to amend the ENCTYPE in the html? I'm just asking ..... again, I trust your knowledge over the lack of mine. I am just thinking about the changes that have been introduced and noting the deficiencies (now) compared to the code and symptoms we had in the beginning.
"old code" ----> email sent, nothing captured, "success" page rendered vs
"new code" ---> no email sent, uncertain if data is being captured, and failure of "success" page being rendered (I see that a "success" page is rendered here : http://dev.wovenland.com/justaguy/) but can't understand why it is failing on the site.
It has to be something quite simple (and evasive) at this point.
I appreciate you hanging in here with me (still)
Fill out form
http://i52.tinypic.com/2dhwuah.jpg
Get Confirmation Page
http://i56.tinypic.com/2j3407s.jpg
Get Confirmation Email
http://i51.tinypic.com/2i25tva.jpg
The email comes almost immediately. Maybe it's getting dumped into your spam folder?
I have been plugging an alternate (working) email address of mine into the form on the web page itself, and typing gibberish, then hitting the "send" button. As part of the script you've put together, the sender (from my web page) receives an e-mail to their e-mail address after completing the form.
This is occurring, the "sender" will receive an email to their inbox and the question they type in the form is remitted to them. The "sender's" email address is formatted as a link that when clicked opens (in this case) a response through gmail.
A little progress, huh? :-)
to this
This way you will receive the email. You can also send them a "Thank you" email with the previous code we were using.
Basically i removed the <> from the to email.
Then I thought, well, I would go back and use the send.php that worked last, the one prior to the last one you submitted. No e-mail.! After making the changes to the "additional headers" and double checking my html.
(what the hell, checkout my site here: nearnorthwebdesign.com
stepping out for a smoke)
There are 2 problems i see with this form code.
1. contactFormprocess.php does not exist on your server. I get a 404 page when i click submit.
2. your enctype="text/plain" will not submit anything to your php file.
Delete your enctype="text/plain". You dont need it at all.
Create contactFormprocess.php on your server and insert the latest send.php code I'm including here.
Really? I know it's not an important issue, but really it actually is. Your code needs to be logical and written properly, using BR tags for spacing is bad coding practise. You should only be using CSS for styling!
Response: contactFormprocess.php isn't being referenced to in my html any longer. That was the name/file for my "old" .php processing. Since working with you I am now simply adopting the send.php name/file to keep from getting (too) confused. I don't see that it is found on the server atm (?)
2. your enctype="text/plain" will not submit anything to your php file.
Response: The enctype for the send.php is "multipart/form-data". I just corrected the "case" of the text to lower case, it was all caps just now.
I don't understand, the issues you are raising here I can't see on the server, unless the number of changes that we've been going through are not being promptly updated on the server, but that's not making sense if you are "seeing" it and I am not (?)
tags aren't necessary, I agree, that was just a carry over from the tutorial.
The form on this page is using this code below.
Is that the page that you have been updating?