mickapoo Posted May 19, 2009 Share Posted May 19, 2009 I have an HTML form that I added a js calendar function to. The user can click the calendar icon, then click on the date that he or she wants from the calendar that pops up. The date that they select is then displayed in the date field. In this form is also a field for them to enter their name and email address. The form gets posted to a php script. My question is, what do I need to do so that the date that is entered will also get sent to my email address? I'm not sure what I need to do to my php file to get the date sent along with the other fields. The name and email address are already sent to my email address, I just need to get the date sent as well. This is my form: <form name="frm" method="post" action="exe_tour2.php" onSubmit="return chk();"> <tr> <td width="17%">Name:</td> <td width="83%"><input type="text" name="name" id="textfield"></td> </tr> <tr> <td>Email address:</td> <td><input type="text" name="email" id="textfield2"></td> </tr> <tr> <td>Preferred wedding date:</td> <td><script>DateInput('orderdate', true, 'DD-MON-YYYY')</script> </td> </tr> <tr> <td> </td> <td><input type="submit" name="button" id="button" value="Book It"></td> </tr> </form> and this is my php code: <?php $mail_msg = $mail_msg."Contact Information\n\n"; $mail_msg = $mail_msg."Name: ".$_POST["name"]."\n"; $mail_msg = $mail_msg."Email Address: ".$_POST["email"]."\n"; $email = $_POST['email']; mail('email@myemail.com', 'Tour Request', $mail_msg, "From: <".$email.">\n\r"); // Mail to user $mail_user = "Auto-Acknowledgement:\n\n Thank you for contacting Mansion.\n We are in receipt of your e-mail and will respond to your inquiry shortly. \n\n Thank you for visiting at http://mansion.org/weddings/ "; mail($email, "Mansion: Auto-Acknowledgement", $mail_user, "From: Mansion<'weddingcenter@mansion.org'>\n\r"); header("Location: thanks.htm"); ?> I'm not sure if I posted everything I need to or not. Don't know if the js file needs to be amended, if so, I can attach it. Thank you for your help! Quote Link to comment Share on other sites More sharing options...
Brian W Posted May 19, 2009 Share Posted May 19, 2009 I don't know what the JS does because you didn't attach or paste the JS... but I'll venture a guess that variable one in the function DateInput() (in yours, it is 'orderdate') is what the JS uses as the input's name & id. Try: <?php $mail_msg = "Contact Information\n\n"; $mail_msg .= "Name: ".$_POST["name"]."\n"; //changed the append to .= because its shorter $mail_msg .= "Email Address: ".$_POST["orderdate"]."\n"; //Here I changed "email" to "orderdate" $email = $_POST['email']; mail('email@myemail.com', 'Tour Request', $mail_msg, "From: <".$email.">\n\r"); // Mail to user $mail_user = "Auto-Acknowledgement:\n\n Thank you for contacting Mansion.\n We are in receipt of your e-mail and will respond to your inquiry shortly. \n\n Thank you for visiting at http://mansion.org/weddings/ "; mail($email, "Mansion: Auto-Acknowledgement", $mail_user, "From: Mansion<'weddingcenter@mansion.org'>\n\r"); header("Location: thanks.htm"); ?> Quote Link to comment Share on other sites More sharing options...
mickapoo Posted May 20, 2009 Author Share Posted May 20, 2009 Thank you very much! It worked perfectly. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.