Jump to content

Php Mail Confirmation


EMP
 Share

Recommended Posts

Hi!I'm trying to send out a mail confirmation based on a form entry. I have two files (1) wmpto_preorder.html which is the form and (2) preorder.php which is the mail confirmation. It acts like it is not getting past the first "if" statement in my php file which I don't understand why. I also tried it without the "if" statement and still got nothing. Can someone point out my error? I know I'm close to figuring out, but I must be overlooking it.Thanks! EMP(1)wmpto_preorder.html<form id="addform" enctype="text/plain" name="addform" method="post" action="preorder.php" onsubmit="return(validate())">(2)preorder.php<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"><html><head> <title>Pre-Order School Supplies Thank You</title> <meta http-equiv="Content-Type" content="text/html; charset=us-ascii" /> <meta name="Language" content="en"> <meta name="Robots" content="index, nofollow"><!-- End Text Tag Name: _META --></head><body><?phpif($_POST) { // Name and E-mail of the Recipient $name_recipient = $_POST['txt_LastName']; $email_recipient = $_POST['txt_EmailAddress']; echo $_POST['txt_LastName']; echo $_POST['txt_EmailAddress']; // The subject of the email $subject = 'Pre-Order School Supplies Confirmation'; // the headers of the email (you can also add a CC or BCC this way) $headers = 'From: Windermere PTO <kp111@hotmail.com>' . "\r\nX-Priority: 2 (High)"; $headers .= 'MIME-Version: 1.0' . "\r\n"; $headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n"; $headers .= 'Reply-To: Windermere PTO <kp111@hotmail.com>' . "\r\nX-Priority: 2 (High)"; $headers .= 'Cc: k123@wideopenwest.com.' . "\r\n"; // message $message = 'This is a test.'; // Ad <br> to the message $bericht = nl2br($message); // Mail it if(mail($email_recipient, $subject, $bericht, $headers)) { echo "Pre-Order Confirmation Sent\n"; echo('<p>Thank you for Pre-Ordering your kid(s) supplies with the Windermere PTO. You will be receiving an email confirmation shortly. Please bring your confirmation to the School Supply Sale on August 21 or August 22 for easy check-out.</p>'); } else { echo "Pre-Order Confirmation Not Sent\n"; }}?></body</html>

Link to comment
Share on other sites

For some reason it is not doing the "Post" command. I just found an article about how it doesn't like _ (underscores) in the name field of the form which I used throughout. I just removed them and I was going to give it a try. I'll let you know if that fixes the problem. I tried putting in this code- foreach ($_POST as $field => $value) { echo "$field, $value<br>"; }-that is how I knew the Post was not working. What do you think? Have you heard about the underscore issue before?

Link to comment
Share on other sites

No, underscores are not a problem. How do you know the post is not working? What does that print? What happens if you use print_r($_POST)?
***********************************************************************************It gives me Array(). And you were right taking away the underscore did not help. What next?
Link to comment
Share on other sites

If no data is being submitted through post, I would look at the Javascript function and figure out if it's modifying anything. I would also look at the form elements to make sure the markup is correct.
I have some javascript functions that are doing some calculations based on the user input. Is that what you mean? But, the calculations are necessary. But, it shouldn't mess with the user last name or email address and I'm not even getting this information. I have looked and looked at the code in my html form page to make sure it is right. I tried checking online sample and looking at books to make sure I did it right that is why I posted a "help" message because I'm at the end my rope. I don't know where else to turn or try. I really don't want post all my code for everyone to see.
Link to comment
Share on other sites

Well, I'm not sure how to help you then. It's conceivable that the Javascript is messing up the form elements somehow, I can't say without seeing it. Try removing the Javascript call and see if it submits normally. Use print_r to print the $_POST array to check on it. If it still doesn't submit without the Javascript, then the problem is most likely in the HTML markup. Also try removing the enctype on the form. If the enctype is being set as the content type for the submit request, if you use text/plain PHP will not automatically parse the request body, you'll need to get it yourself in the $HTTP_RAW_POST_DATA variable. The normal content type for a form is x-www-form-urlencoded, which the browser will set automatically.

Link to comment
Share on other sites

Well, I'm not sure how to help you then. It's conceivable that the Javascript is messing up the form elements somehow, I can't say without seeing it. Try removing the Javascript call and see if it submits normally. Use print_r to print the $_POST array to check on it. If it still doesn't submit without the Javascript, then the problem is most likely in the HTML markup. Also try removing the enctype on the form. If the enctype is being set as the content type for the submit request, if you use text/plain PHP will not automatically parse the request body, you'll need to get it yourself in the $HTTP_RAW_POST_DATA variable. The normal content type for a form is x-www-form-urlencoded, which the browser will set automatically.
I just removed the enctype which isn't necessary from my form and everything works great now. I got the POST to work great. Now, I'm going to start working on my message of the confirmation part which is always a challenge mixing html and PHP code. Thanks for helping me work through my POST problem. I have about a week before I have to be totally finished. I was starting to stress out a little bit. Thanks again!
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...