hi,
i want to store date time whan i click radio button(name login time)in mysql. if i click logout radio button it should store logout time. ples help me... php and mysql code ...

You can use NOW() in your MySQL query which will store the current date and time.

thanks for reply. i used NOW() in query but i getting same datetame in login and logout column.
this is radio button code:

<input type="radio" name="login"  >LogIn
<input type="radio" name="logout">LogOut

and

<?php
$con = mysql_connect("localhost","root","");
if (!$con)
{
die('Could not connect: ' . mysql_error());
}
$data_base="log";
mysql_select_db($data_base, $con);
if($_SERVER['REQUEST_METHOD']=="POST"){
$name = $_POST['name'];
$empid = $_POST['empid'];
$shift = $_POST['shift'];
$login = $_POST['login'];
$logout = $_POST['logout'];

$login = 'unchecked';
$logout = 'unchecked';

if (isset($_POST['Submit'])) {

$selected_radio = $_POST['log'];

if ($selected_radio == 'login') {

$login = 'checked';

}
else if ($selected_radio == 'logout') {

$logout = 'checked';

}}

$sql="INSERT INTO emp (name,empid,shift,login,logout)VALUES ('$name','$empid','$shift',now(),now())";
if (!mysql_query($sql,$con))
{
die('Error: ' . mysql_error());
}
}

echo "Your Information Was Successfully Posted";
include('thankyou.php');
mysql_close($con);
?>

ple help me.

You should only update the login column when logging in, and the logout column when logging out, not both at the same time.

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.