So I really don't know what I'm going to set the title on this one to, generally couldn' come up with anything good. Still though, if you are reading this I will do my best to explain it here.
I am trying to check if the currently logged in user equals to the one on the current profile management page, an example:
Currently logged in user: Bob
If bob is looking at his own profile page, he should see a "Edit" button, however, if he is looking at the profile page of "Peter", he should not. I've been trying a lot of different ways, the one I thought would work was doing a if session equals username variable, but with no result.
The issue I am looking at is, either it displays nothing at all, a blank page as far as that goes (except for the background and whatnot), OR Bob as used in the example has access to all edit buttons, which isn't right either.
Also, What I have right now if its to any use:
DB connection:
<?php
// error_reporting(E_ALL);
session_start();
$host = 'HOSTNAME';
$dbusername = 'DATABASENAME';
$dbpassword = 'PASSWORD';
$anslutning = mysqli_connect($host, $dbusername, $dbpassword) or die("<b>Could not connect to database server</b>");
$anslutning->select_db('DATABASE NAME') or die("<b>Could not connect to the specified database</b>");
?>
The profile management page this far:
if(isset($_GET['manage'])) {
$manage = $_GET['manage'];
$editAccount = $anslutning->prepare('SELECT userId, username, email, gender, age, profilePic FROM (tablename) WHERE userId=? LIMIT 1');
$editAccount->bind_param("i", $manage);
$editAccount->bind_result($userId, $username, $email, $gender, $age, $profilePic);
$editAccount->store_result();
$editAccount->execute();
echo '<h2 class="accountm_title">Account management</h2>';
if(isset($_SESSION['loggedIn'])) {
echo '
<i><a class="edit" href="index.php?editAccount='.$userId.'">Edit</a></i>
<hr size="1" width="30%" class="manageHr">
<div class="accountm">
';
}
while($row = $editAccount->fetch()) {
echo '
<form action="index.php" method="GET">
<p>Username: '.$username.' </p>
<p>Email: '.$email.' </p>
<p>Gender: '.$gender.'</p>
<p>Age: '.$age.' </p>
<p>Profile picture: <img src="'.$profilePic.'"></p>
</form>
';
}
}
Then some code updating the database with the fields, which seems to work.