Jump to content

[SOLVED] Form with js calendar script that gets posted to a php file


mickapoo

Recommended Posts

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!

Link to comment
Share on other sites

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");

?>

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.