Hello,

I am using a java script to select a date from date picker.After selecting date from calender,it shown in the text box but it is not saved in the database.

In database takes this value 0000-00-00 for every date.

Please suggest me any idea for above.
Thanks

Show the code. Are you updating the database at all?

Hi,This is code

<?php
$host="localhost"; // Host name
$username="root"; // Mysql username
$password=""; // Mysql password
$db_name="ihmjob"; // Database name
$tbl_name="ihm"; // Table name

// Connect to server and select database.
mysql_connect("$host", "$username", "$password")or die("cannot connect server ");
mysql_select_db("$db_name")or die("cannot select DB");

if(isset($_POST['submit']))//for email
{
	$subject=$_POST['subject'];
	$desc=$_POST['desc'];
    $category=$_POST["category"];
	$experience=$_POST['experience'];
	$location=$_POST['location'];
	$company=$_POST['company'];
	$dop=$_POST['dop'];
	
	
    if (empty($_POST['subject']) || empty($_POST['desc']) || empty($_POST['category']) || empty($_POST['experience'] ))
		  {
 			 	echo "<script type=\"text/javascript\">";
				echo "alert('Please Enter Mandatory Fields !!');";
				echo "</script>";	
				echo "<script type=\"text/javascript\">";
		  }	

	else
	{ 
		
        $result= mysql_query("INSERT INTO `ihm` (`subject`, `desc`, `category`, `experience`, `location` ,`company` ,`dop`) VALUES ('$subject', '$desc', '$category', '$experience', '$location' ,'$company' ,'CURDATE()');");
      
	}   




}

?>

I also used that code when we manually select date from datepicker.

$result= mysql_query("INSERT INTO `ihm` (`subject`, `desc`, `category`, `experience`, `location` ,`company` ,`dop`) VALUES ('$subject', '$desc', '$category', '$experience', '$location' ,'$company' ,'$dop');");

Hi,This is code

if(isset($_POST['submit']))//for email
{
	$subject=$_POST['subject'];
	$desc=$_POST['desc'];
    $category=$_POST["category"];
	$experience=$_POST['experience'];
	$location=$_POST['location'];
	$company=$_POST['company'];
	$dop=$_POST['dop'];

1. Go read this:http://www.tizag.com/mysqlTutorial/mysql-php-sql-injection.php
2. Implement this: http://php.net/manual/en/function.mysql-real-escape-string.php
3. Never trust submitted values

if(isset($_POST['submit']))//for email
        $result= mysql_query("INSERT INTO `ihm` (`subject`, `desc`, `category`, `experience`, `location` ,`company` ,`dop`) VALUES ('$subject', '$desc', '$category', '$experience', '$location' ,'$company' ,'CURDATE()');");

Why have you got );"); at the end?
Correct structure for your query is:

mysql_query("INSERT INTO `...` (`...`, `...`, `...`) VALUES('...', '...', '...')");

Concerning your date issue, remove the single quotes around CURDATE(). This is a function, yet you insert it as a string.

when u pick a date from your calender how does it look in the text field

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.