0

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

2
Contributors
3
Replies
22
Views
4 Years
Discussion Span
Last Post by pritaeas
0

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.

0

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

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.