My friend and I are very close to finishing our webpage, and we have hit several snags. For example, when we log into our login page takes us to another page with the following code:
In advance thanks for even reading this far.
CODE 1:
<?php
$dbcnx = @mysql_connect('localhost', 'root');
if (!$dbcnx) {
exit('<p>Unable to connect to the ' .
'database server at this time.</p>');
}
if (!@mysql_select_db('website')) {
exit('<p>Unable to locate the joke ' .
'database at this time.</p>');
}
?>
<h1>Welcome to Members' area!</h1>
<a href="member-profile.php?firstname=<?php echo urlencode($_GET['firstname']);?>">My Profile</a> | <a href="logout.php">Logout</a>
<p>This is a password protected area only accessible to members. </p>
</body>
</html>
After we click the "My Profile" link we are sent to another page with the following code:
CODE 2:
<?php
$dbcnx = @mysql_connect('localhost', 'root');
if (!$dbcnx) {
exit('<p>Unable to connect to the ' .
'database server at this time.</p>');
}
if (!@mysql_select_db('website')) {
exit('<p>Unable to locate the joke ' .
'database at this time.</p>');
}
// Request the ID and firstname
$result = @("SELECT member_id, firstname FROM members");
if (!$result) {
exit('<p>Error performing query: ' .
mysql_error() . '</p>');
}
// Display username
while ($row = mysql_fetch_array($result)) {
$member_id = $row['member_id'];
$firstname = $row['firstname'];
echo '<p>' . $firstname . '</p>';
}
?>
The problem we are having is that between these two pages, the "My Profile" page (CODE 2) is showing all the names in the database as opposed to just the name of the user who is logged in to the website. Any suggesstions?