Hi I am trying to create a log system were users can log activities, once they are logged in their username is held in a session. My problem is I want them to be able to create a new log by filling out a form but I don't want them to have to enter their user name every time rather grab the username from the session and pop it into the insert statement. Here is the code I would greatly appreciate any help asap as it is for a project with looming deadline. Cheers.
<?php
session_start();
if(!session_is_registered("myusername")){
header("location:main_login.php");
}
include 'topmembers.php';
?>
<div id="page" class="container">
<!--First Post--> <div id="content">
<div class="post">
<?php
$con = mysql_connect("localhost","root","root");
if (!$con)
{
die('Could not connect: ' . mysql_error());
}
mysql_select_db("newcastle", $con);
$sql="INSERT INTO log (logid, username, logdate, type, totaltime_mins, total_distance, notes)
VALUES (Null,'".$_SESSION['myusername']."',$_POST[logdate]','$_POST[type]','$_POST[totaltime_mins]', '$_POST[total_distance]','$_POST[notes]')";
echo .$_SESSION['myusername']
?>
<?php
if (!mysql_query($sql,$con))
{
die('Error: ' . mysql_error());
}
echo "Log Saved";
mysql_close($con)
?>
</div>
</div>
<?php
include 'websiteend.php';
?>
It simply returns a blank page