Log in

View Full Version : calendar usage in html forms and getting the values in php



Cathe
06-25-2015, 09:57 AM
hi,

I used the calendars in a html form which displays the month and year. So the user can select the month and year.
And I have a php coding which saves the details in the html form to mysql database. If I 'm using the "dynamic calendars"
in this website... which allows me to paste some coding into the 'body' section of my page and the 'body' tag and download a
"calendar.js" script in the same directory of which I'm using. How will I get the values using the POST or GET method in php?

or is there anyother better way to use calendars and recieve the values in a variable in php. Can someone help me out?
Thanks in advance.

Beverleyh
06-25-2015, 01:48 PM
Its impossible for anyone to help without a link to the source calendar script, and your web page.

- If you are using a script from another website, please provide the link to the website page where the calendar can be seen in action.
- If you are using a script from Dynamic Drive, please follow the correct posting format as detailed in this post http://www.dynamicdrive.com/forums/showthread.php?t=6

You should also provide a link to your website where the calendar script is installed ON YOUR WEBSITE so that we can see the problem and/or what you're working with.

Cathe
06-26-2015, 03:55 AM
Thanks for the format...

I 'm just a beginner with PHP and mySQL. Presently practicing with XAMPP v5.6.8(PHP v5.6.8). I use drop down lists to select the month and year in a html form like the the coding below:

In "XXXX.php"


<html>
<head><title>Sales Commission </title>
</head>
<body>
...
<p>Month :
<input type="month" name="Month">
<select name = "Month">
<option value="January">January</option>
<option value="February">February</option>
<option value="March">March</option>
<option value="April">April</option>
<option value="May">May</option>
</select>
similarly a dropdown list for the "year" with a
<form action='<?php $_SERVER['PHP_SELF'] ?>' method="POST">
<input type="submit" name="submit" value="Submit">

and then the php code in the same page
<?php

// Connect to database server
mysql_connect("localhost", "username", " ") or die (mysql_error ());

// Select database
mysql_select_db("mydatabase") or die(mysql_error());

// receive the variables using the POST method
$a=$_POST['Month'];
$b=$_POST['year'];

// The SQL statement is built

$strSQL = "INSERT INTO salesdata(Month, year) VALUES ('$a', '$b')";

";

// The SQL statement is executed
mysql_query($strSQL) or die (mysql_error());

// Close the database connection
mysql_close();
?>
But if I use the calendar script from a website
Script name : Dynamic Calendar
http://www.dynamicdrive.com/dynamicindex6/dcalendar.htm

when user selects a month or year in the form, how to receive data in php and insert it into the database

How to store it in a mysql database in XAMPP? or in anyother database... Any suggestions on how to learn advanced stuffs in PHP.. books? websites?

Hope I'm clear...
Thanks

Beverleyh
06-26-2015, 05:19 AM
I dont think that script is suitable for your needs. Try looking for something else using keywords "date picker" or "calendar to form input field". Or start here http://www.bitrepository.com/a-collection-of-free-javascript-date-pickers.html

Of the options on DD, this looks most suitable: http://www.dynamicdrive.com/dynamicindex7/jasoncalendar.htm

Once JavaScript inserts the date into your form's date field, is should be processed automatically by your php script.

Look for options within the date picker config (of whichever script you choose) that allow you to specify date format so that the date is in the right format for the php to process as soon as it goes in to the input field.

If you need more help, post back with your script selection AND A LINK TO THE PAGE ON YOUR WEBSITE!