Jump to content

I m not able to send startdate using post


bhavya

Recommended Posts

This is my html code

<html>

<head>

<title>Home Page</title>

</head>

<body>

<form name="input" action="db.php" method="post">

<h2>Employee Details</h2>

    First name:

<input type="text" name="firstname" size="20">

<br>Last name :

<input type="text" name="lastname" size="20">

<br>Email id :

<input type="text" name="Emailid">

<br>start Date:

<input type="datetime" name="startdate ">

<br>Salary  :

<input type="int" name="salary">

<br>JobTitle  :

<input type="text" name="jobtitle">

<br>

<input type="submit" value=" submit ">

<br>

<a href ="appl.htm"  target="_blank">Print appointment Letter</a>

</form>

 

</body>

</html>

 

db.php

 

<?php

//Retrieving data from the form

function checkOK($field)

{

if (eregi("\r",$field) || eregi("\n",$field)){

die("Invalid Input!");

}

}

 

$firstname=$_POST['firstname'];

checkOK($firstname);

$lastname=$_POST['lastname'];

checkOK($lastname);

$emailid= $_POST['Emailid'];

checkOK($emailid);

$startdate=stripslashes($_REQUEST['startdate']);

$salary=$_REQUEST['salary'];

$jobtitle=$_POST['jobtitle'];

checkOK($jobtitle);

echo $startdate;

 

 

$myServer = "BHAVYA-PC\SQLEXPRESS";

$myUser = "";

$myPass = "";

$IntegratedSecurity = "yes";

$myDB = "Employees";

 

 

//connection to the database

$dbhandle = mssql_connect($myServer, $myUser, $myPass,$IntegratedSecurity)

  or die("Couldn't connect to SQL Server on $myServer");

 

//select a database to work with

$selected = mssql_select_db($myDB, $dbhandle)

  or die("Couldn't open database $myDB");

 

//declaring the SQL statement that will query the database

//$query = "insert into table emprecords values($firstname,$lastname,$emailid,$startdate,$salary,$jobtitle)";

$query = "insert into emprecords values('".$firstname."','".$lastname."','".$emailid."','".getdate()."','".$salary."','".$jobtitle."')";

 

 

//execute the SQL query and return records

$result = mssql_query($query);

 

 

//close the connection

mssql_close($dbhandle);

?>

 

I am not able to display startdate that was entered in the form in db.php.when submit button was clicked i need to send form data to db.php and i need to save it in the database.i don't have problem with the other fields but start date field was displaying default date in database.

can anyone please help me.

It's urgent please.

 

getdate returns an associative array, so it must be handled accordingly.

 

why not use date instead?

 

<?php
$date = date ('Y-m-d');
echo $date; //prints 2009-12-17 (which is today .. where i live, anyways);
?>

 

It's urgent please.

 

unless you are willing to employ, please be patient.

i need to save the date that was entered in the form in sql server.with $date=date('y/m/d'); i m able to save todays date what changes i need make to save the entered date.

 

if it's being manually entered in the form, treat it as you would any other variable.  there is no HTML date formatting tool for forms.  if you want something like that, look into javascript.

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.