Note that there are some explanatory texts on larger screens.

plurals
  1. POTrying to set $_SESSION['username'] in functions include
    primarykey
    data
    text
    <p>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..</p> <pre><code>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; } </code></pre> <p>So I can insert them into mysql with a string such as</p> <pre><code>$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(); </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload