Click here to Skip to main content
15,896,453 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
PHP
session_start();
include 'connect.php';


$sql = "UPDATE attendance SET logouttime = NOW() WHERE id = '$_SESSION($_POST[id])'"; 

mysql_query($sql);

	
session_destroy();
header('Refresh: 0; URL = login.php');
?>

It wont store the logouttime, i dont know whats wrong
Posted
Updated 1-Feb-15 0:09am
v2

1 solution

You have forgotten to quote the id inside the $_POST, i.e. $_POST["id"]
But why a $_POST inside a $_SESSION? Could it be either:
$sql = "UPDATE attendance SET logouttime = NOW() WHERE id = '".$_SESSION["id"]."'";

or
$sql = "UPDATE attendance SET logouttime = NOW() WHERE id = '".$_POST["id"]."'";

However, you should consider the following:
1. Switching to mysqli extension[^] as the ext/mysql extension has been deprecated [^]since PHP 5.5.
2. Use prepared statement[^] for the sql
 
Share this answer
 
v5

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900