Web Hosting Talk







View Full Version : Java Calender Mail to


SpaciousHost
07-24-2009, 05:58 AM
Hi all, I have a contact form:
<?php $thisPage="reserve"; ?>
<script src="jquery.ui-1.5.2/jquery-1.2.6.js" type="text/javascript"></script>
<script src="jquery.ui-1.5.2/ui/ui.datepicker.js" type="text/javascript"></script>
<link href="jquery.ui-1.5.2/themes/ui.datepicker.css" rel="stylesheet" type="text/css">
<form method="post" action="?p=send" name='booking1' onsubmit="return checkFields();">
<!-- BEGIN -->
<link type="text/css" rel="stylesheet" href="skyblue.css" >

<!-- END -->
<!-- Warning function -->
<script type='text/javascript'>
function checkFields()
{
if (document.getElementById('fname').value == '')
{
alert('Please enter your first name!');
return false;
}

if (document.getElementById('lname').value == '')
{
alert('Please enter your last name!');
return false;
}


if (document.getElementById('email').value == '')
{
alert('Please enter your email!');
return false;
}
if (document.getElementById('phone').value == '')
{
alert('Please enter your phone number!');
return false;
}
if (document.getElementById('date').value == 'Click me!')
{
alert('Please select a date!');
return false;
}


if (document.getElementById('rhr').value == 'sel')
{
alert('Please enter a time!');
return false;
}

if (document.getElementById('rmin').value == 'sel')
{
alert('Please enter a time!');
return false;
}

if (document.getElementById('ampm').value == 'sel')
{
alert('Please enter a time!');
return false;
}

if (document.getElementById('nguests').value == '')
{
alert('Please enter the amount of guests!');
return false;
}
return true;

}

</script>

<!-- DO NOT change ANY of the php sections -->
<?php
$ipi = getenv("REMOTE_ADDR");
$httprefi = getenv ("HTTP_REFERER");
$httpagenti = getenv ("HTTP_USER_AGENT");
?>
<style type="text/css">
<!--
.ralign {
text-align: right;
}
-->
</style>
<style type="text/css">
<!--
.right {
text-align: right;
}
-->
</style>
<body>

</head>

<body>
<cfif IsDefined("form.jQueryUICalendar1")>
</cfif>
<table width="742" height="309" border="0">
<tr>
<td colspan="4"><center>
</center></td>
</tr>
<tr>
<td width="100" class="right">First Name:</td>
<td width="210"><input type='textbox' name='fname' id='fname' class="input"/></td>
<td width="129">Date of Reservation:</td>


<td><input type="text" size="30" value="Click to select date" id="date" class='input'/>
<script type="text/javascript">
// BeginWebWidget jQuery_UI_Calendar: jQueryUICalendar1
jQuery("#jQueryUICalendar1").datepicker();

// EndWebWidget jQuery_UI_Calendar: jQueryUICalendar1
</script></td>

</tr>
<tr>
<td class="right">Last Name:</td>
<td><input type='textbox' name='sname' id='lname' class="input" /></td>
<td>Time of Reservation:</td>
<td><select name='rhr' id='rhr' class="input" value='Select'>
<option value='sel'></option>
<?php
for ($i=1;$i<13;$i++)
{ echo "<option value='".$i."'>".$i."</option>";
}
?>
</select>
:
<select name='rmin' id='rmin' class="input" value=''>
<option value='sel'></option>
<option value='00'>00</option>
<option value='15'>15</option>
<option value='30'>30</option>
<option value='45'>45</option>
</select>
|
<select name='ampm' id='ampm' class="input" value=''>
<option value='sel'></option>
<option value='am'>AM</option>
<option value='pm'>PM</option>
</select></td>
</tr>
<tr>
<td class="right">Email:</td>
<td><input type='textbox' name='email' id='email' class="input" /></td>
<td>Number of Guests:</td>
<td><input type='textbox' id='nguests' name='nguests' class="input" /></td>
</tr>
<tr>
<td class="right">Phone:</td>
<td><input type='textbox' name='phone' id='phone' class="input" /></td>
<td>Special Requests: </td>
<td><textarea id='specreq' name='specreq' class="input"></textarea></td>
</tr>
<tr>
<td colspan="3"><strong>To make a booking for today, please contact us on 9510 2820</strong></td>
<td><input type="image" src="images/submit.gif" height="25" width="125" border="0" alt="Submit Form"></td>
</tr>
</table>
<p>&nbsp; </p>
<p></p>
<script type="text/javascript">
<!--
jQuery("#jQueryUICalendar1").datepicker();
//-->
</script>
</body>


The Send Form
[/<?php
$from = "myemail@mydomain.com";
$ip = $_SERVER['REMOTE_ADDR'];
$to = 'myemail@mydomain.com'; // This would be your email
$subject = $_POST['fname'] . " " .$_POST['lname'] ." has submitted a reservation for Vin Cellar.";
$body = "First Name: ".$_POST['fname']." \n
Last Name: ".$_POST['sname']." \n
Email Address: ".$_POST['email']." \n
Telephone Number: ".$_POST['phone']." \n
Date of Reservation: ".$_POST['date']." \n
Time of Reservation: ".$_POST['rhr'].":".$_POST['rmin']." ".$_POST['ampm']."
Number of People: ".$_POST['nguests']." \n
Special Requests: ".$_POST['specreq']." \n
IP: ".$ip." \n";
mail($to,$subject,$body, $from);
?>

<center>
<div><h3>Thank you for your reservation enquiry, we will be in
touch to confirm shortly.</h3><p>If you have not heard from us within two days.</p><div>
</center>
For some reason it doesn't email the date through.
The email looks like this:

First Name: Name

Last Name: Name

Email Address: myemail@mydomain.com

Telephone Number: 000000000

Date of Reservation:

Time of Reservation: 3:30 pm
Number of People: 15

Special Requests: No.

JulesR
07-28-2009, 02:15 AM
Your date input field doesn't have a name attached to it, so won't be passing PHP any information:

<input type="text" size="30" value="Click to select date" id="date" class='input'/>

Add a name="date" parameter and you should be good to go :)