commented profile.php

This commit is contained in:
Thies Mueller 2021-01-12 17:19:05 +01:00
parent 05b9ad12fa
commit 998f4331ae

View File

@ -1,10 +1,10 @@
<?php
session_start();
if(!isset($_SESSION['userid'])) {
session_start(); //start a session
if(!isset($_SESSION['userid'])) { //if there isnt a session print a please login page and go to login page
die('<div class="alert alert-primary" role="alert">Please <a href="login.php">login</a></div><meta http-equiv="refresh" content="2; URL=login.php">');
}
//for easier use we shove some of the session array into variables.
$userid = $_SESSION['userid'];
$username = $_SESSION['username'];
$useremail = $_SESSION['email'];
@ -13,6 +13,8 @@ $userln = $_SESSION['lastName'];
$activated = $_SESSION['activated'];
$isadmin = $_SESSION['isadmin'];
$profilepicture = $_SESSION['profilepicture'];
//lets build a page:
?>
<html>
<head>
@ -33,9 +35,10 @@ $profilepicture = $_SESSION['profilepicture'];
<?php
//print a info bar with the username
echo '<div class="alert alert-info" role="alert">Profile of '.$username.'</div>';
echo "<br/>";
//lets build a table with infos:
echo '<table class="table table-dark table-striped" style="width:30%">';
echo "<tr>";
echo "<td>";
@ -82,16 +85,17 @@ echo "</tr>";
<br /> <br /><br />
<table class="table table-dark table-striped" style="width:30%">
<?php
//another table just for "activated" & "isadmin"
echo "<tr>";
echo "<td>";
echo "User Status:";
echo "</td>";
echo "<td>";
if ($activated == 0) {
if ($activated == 0) { //if not activated print it in red and render a activation link
echo '<p class="text-danger">Not Activated!</p><br>';
echo 'Click <a href="activation.php">here</a> to activate';
}
if ($activated == 1) {
if ($activated == 1) { //if activated print so, but in green
echo '<p class="text-success">Activated!</p>';
}
echo "</td>";
@ -101,14 +105,15 @@ echo "<td>";
echo "User Level:";
echo "</td>";
echo "<td>";
if ($isadmin == 0) {
if ($isadmin == 0) { //if not admin, print "User" in green
echo '<p class="text-success">User</p><br>';
}
if ($isadmin == 1) {
if ($isadmin == 1) { //if admin, print so but in red
echo '<p class="text-danger">Admin</p>';
}
echo "</td>";
echo "</tr>";
//some html:
?>
</table>