As the topic states, I am using my functions include file to try and setup "$\_SESSION['username']" so that I can use it as an insert value on parts of my site, but I am having no luck..

```
function change_profile_image($user_id, $file_temp, $file_extn) {
$file_path = 'images/profile/' . substr(md5(time()), 0, 10) . '.' . $file_extn;
move_uploaded_file($file_temp, $file_path);
mysql_query("UPDATE `users` SET `profile` = '" . mysql_real_escape_string($file_path) . "' WHERE `user_id` = " . (int)$user_id);
}

function mail_users($subject, $body) {
$query = mysql_query("SELECT `email`, `first_name` FROM `users` WHERE `allow_email` = 1");
while (($row = mysql_fetch_assoc($query)) !== false) {
    email($row['email'], $subject, "Hello " . $row['first_name'] . ",\n\n" . $body);
}
}
   function login($username, $password) {
$user_id = user_id_from_username($username);

$username = sanitize($username);
$username = $_SESSION['username'];
$password = md5($password);

return (mysql_result(mysql_query("SELECT COUNT(`user_id`) FROM `users` WHERE `username` = '$username' AND `password` = '$password'"), 0) == 1) ? $user_id : false;
}

```

So I can insert them into mysql with a string such as

```
$category=$_POST['category'];
$sub_category=$_POST['sub_category'];
$topic_data=$_POST['topic_data'];
$posted=date("h:i:s d/m/Y"); //create date time

$sql="INSERT INTO `topics`(category, sub_category, topic_data, posted_by, posted)VALUES('$category', '$sub_category', '$topic_data', '" . $_SESSION['username'] . "', '$posted')";
$result=mysql_query($sql);

if($result){
header("Location: topics.php");
exit();

```