Hello everyone.
Willy in HTMLforums posted a great Date Range selector script. It is written in JS and I am trying to stick it in my PHP form/script.
The form and form functions work great. But I don't know how to grab the date from the JS and insert it into my PHP sql insert command.
An excerpt from the form:
<tr>
<td width='22%'> <div align="left"><strong><font color="#FF0000" face="Georgia, Times New Roman, Times, serif">Event
title: </font></strong></div></td>
<td width='78%'><input name="event_title" type="text" size="30">
</td>
</tr>
<tr>
<td><strong><font color="#FF0000" face="Georgia, Times New Roman, Times, serif">Start
date:</font></strong></td>
<td> <script type="text/javascript">startDate()</script> </td>
</tr>
<tr>
<td valign="top"><strong><font color="#FF0000" face="Georgia, Times New Roman, Times, serif">End
date:</font></strong></td>
<td><script type="text/javascript">endDate()</script>
</td>
</tr>
<tr>
<td><strong><font face="Georgia, Times New Roman, Times, serif">Start
time(s):</font></strong></td>
<td> <input name="event_time" type="text" size="30"> </td>
</tr>
My form insert script:
<?
$DBhost = "localhost";
$DBuser = "xxxxx";
$DBpass = "xxxxx";
$DBName = "vector2_events";
$table = "events_yxh";
mysql_connect($DBhost,$DBuser,$DBpass) or die("Unable to connect to database");
@mysql_select_db("$DBName") or die("Unable to select database $DBName");
if ($_POST[event_enddate] == "2004-mm-dd"){
$_POST[event_enddate] = $_POST[event_startdate];}
$sqlquery = "INSERT INTO events_yxh (event_title, event_startdate, event_enddate, event_time, event_location, event_venue, event_description, event_contact, event_phone, event_fax, event_website, event_email, event_special)
VALUES ('$_POST[event_title]', '$_POST[event_startdate]', '$_POST[event_enddate]', '$_POST[event_time]', '$_POST[event_location]', '$_POST[event_venue]', '$_POST[event_description]', '$_POST[event_contact]', '$_POST[event_phone]', '$_POST[event_fax]', '$_POST[event_website]', '$_POST[event_email]', '$_POST[event_special]')";
$results = mysql_query($sqlquery);
mysql_close();
$message = "An event has just been submitted. The event is '$_POST[event_title]'";
mail("me@me.com", "An event has been submitted", $message,
"From: [email]me@me.com[/email]\r\n" .
"Reply-To: [email]me@me.com[/email]\r\n" .
"X-Mailer: PHP/" . phpversion());
if ($_POST[event_special] == 0) {header('location: <a href="http://www.me.com/index.php?thankyou=1" target="_blank">[url]http://www.me.com/index.php?thankyou=1[/url]</a>');}
if ($_POST[event_special] != 0) {header('location: <a href="http://www.me.com/index.php?thankyoupay=1" target="_blank">[url]http://www.me.com/index.php?thankyoupay=1[/url]</a>');}
?>
This PHP script references the event_startdate and event_enddate as this is what i used to call these fields. I would like to retain these names. Willy tells me that his script uses startDay, startMonth and startYear.
So how do I get startDay, startMonth and startYear in JS to be a PHP string in the yyyy-mm-dd configuration?
Willy's script is at http://www.htmlforums.com/attachment.php?s=&postid=235612
Thanks!