Unable to insert session id to database. I Want to get the session username and insert it to database and display the current session username content.
<?php
require("session.php");
require ("include.php");
if (isset($_POST['save'])) {
if (
!empty($_POST['name']) && !empty($_POST['subject']) && !empty($_POST['sender']) &&
!empty($_POST['to']))
{
$session_id = $_SESSION["user"];
$name = $_POST['name'];
$subject = $_POST['subject'];
$sender = $_POST['sender'];
$to = $_POST['to'];
$time = date("Y-m-d H:i:sa");
foreach ($name as $key => $names) {
$s_name = $names;
$s_subject = $subject[$key];
$s_sender = $sender[$key];
$s_to = $to[$key];
$save = mysqli_query($link,"INSERT INTO `incomings`( `name`, `subject`,`sender`, `to_`,
`session_id`, `time`) VALUES ('$s_name','$s_subject','$s_sender',
'$s_to','$session_id', '$time' )");
$save_q = mysqli_query($link,$save);
}
if (!$save) {
echo " Mails Not Submitted!";
header("Location:insert_incoming.php");
exit(0);}
}
}
?>