I am having a problem getting the data from my sql database using session's. I am trying to make a log-in system. I already have this working but every use gets directed to the same page - I want private profiles on it that can only be viewed by the person logging in with the correct email address and password.
I am using the following code - I am getting an error on line 19! If I'm honest I dont 100% understand this line - I am new to PHP and SQL and have been reading up about all of this but not getting an answer that fully explains it to me.
Any help would be appreciated - referring me to a tutorial any thing...
<?php # DISPLAY COMPLETE FORUM PAGE.
# Access session.
session_start() ;
# Redirect if not logged in.
if ( !isset( $_SESSION[ 'user_id' ] ) ) { require ( 'login_tools.php' ) ; load() ; }
# Set page title and display header section.
$page_title = 'Forum' ;
# Open database connection.
require ( 'connect_db.php' ) ;
# Display body section, retrieving from 'forum' database table.
$q = "SELECT * FROM users WHERE user_id = $_SESSION[email]" ;
$r = mysqli_query( $dbc, $q ) ;
if ($result = $mysqli->query("SELECT * FROM users"))
{
echo '<table><tr><th></th><th></th><th id="msg"></th></tr>';
while ( $row = mysqli_fetch_array( $r, MYSQLI_ASSOC ))
{
echo '<tr><td>' . $row['first_name'] .' '. $row['last_name'] . '<br>'. $row['email'].'</td>
<td>','</td><td>','</td> </tr>';
}
echo '</table>' ;
}
else { echo '<p>There are currently no messages.</p>' ; }
# Create navigation links.
#echo '<p><a href="post.php">Post Message</a> | <a href="shop.php">Shop</a> | <a href="home.php">Home</a> | <a href="goodbye.php">Logout</a></p>' ;
# Close database connection.
mysqli_close( $dbc ) ;
?>