Thursday, 19 September 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

php - file_get_contents shows unexpected output while reading a file

I want to output an inline jpg image as a base64 encoded string, however when I do this : $contents = file_get_contents($filename); print ...