Thursday, September 19, 2019

php - How can i store data in login datetime table?

my project is to create a journal for diabetic patients. First, when the user logging in, the timestamp will be captured and inserted into the database. And then when the user go to next page to insert blood glucose data, the data cannot be inserted into the same table as the timestamp (login time) . I used sessions but it showed error on the blood glucose page. So here is my coding :-






// Start the session
session_start();
if (isset($_SESSION['time_id'])) {
include 'connection.php';
$time_id = $_SESSION['time_id'];
$query = "SELECT * FROM journal WHERE time_id = '$time_id'";
$result = mysql_query($query) or die(mysql_error());
$row = mysql_fetch_array($result, MYSQL_ASSOC);
}


$bloodglucose = $_POST['bloodglucose'];
$time_id = $_SESSION['time_id'];
$bloodpressure = 0.0;
$qry = mysql_query("INSERT INTO journal VALUES ('" . $time_id . "','" . $row2['user_id'] . "','" . $bloodglucose . "','" . $bloodpressure . "')");
if ($qry) {
echo "";
echo "";
} else {
echo "Sorry, your data failed to be added to the database
";

}
?>











 Blood glucose level (mg/dl) :











No comments:

Post a Comment

hard drive - Leaving bad sectors in unformatted partition?

Laptop was acting really weird, and copy and seek times were really slow, so I decided to scan the hard drive surface. I have a couple hundr...