profile.php (1608B)
1 <html> 2 <?php 3 include_once 'res/session.php'; 4 include_once 'config.php'; 5 if($_SESSION['username'] == null) 6 header("Location: login.php"); 7 8 $user = $_SESSION['username']; 9 $email = $_SESSION['email']; 10 $uid = $_SESSION['uid']; 11 $date = date("M j, Y",strtotime($_SESSION['date'])); 12 $block = $_SESSION['blocked']; 13 14 $blockStatus = ""; 15 16 if($block == 48) { 17 $blockStatus = "full access"; 18 } elseif($block == 49) { 19 $blockStatus = "cannot create surveys"; 20 } elseif($block == 50) { 21 $blockStatus = "cannot take or create surveys"; 22 } elseif($block == 51) { 23 $blockStatus = "r.i.p."; 24 } 25 26 include 'res/navbar.php'; 27 28 echo '<link rel="stylesheet" href="res/style.css">'; 29 echo '<div class="profile">'; 30 31 32 echo "<h2> Username: $user </h2>"; 33 echo "<h2> Email: $email </h2>"; 34 echo "<h2> UserID: $uid </h2>"; 35 echo "<h2> User Registration Date: $date </h2>"; 36 echo "<h2> Blocked Status: $blockStatus </h2>"; 37 38 $sql = "SELECT title FROM survey WHERE survey_id IN (SELECT survey_id FROM answer_numeric WHERE user_id=$uid) ORDER BY RAND() LIMIT 3;"; 39 $result = mysqli_query($connect, $sql); 40 41 echo "Recent surveys that ", $user, " has taken: <br>"; 42 while ($surveys_taken = mysqli_fetch_assoc($result)) { 43 echo $surveys_taken['title'], "<br>"; 44 } 45 echo "<br> <br>"; 46 47 $sql = "select title, access_code from survey where user_id=$uid order by creation_date desc limit 1;"; 48 $result = mysqli_query($connect, $sql); 49 $newest_survey = mysqli_fetch_assoc($result); 50 51 echo $user, "'s newest survey: ", $newest_survey['title'], "<br>"; 52 echo "Access code: ", $newest_survey['access_code'], "<br>"; 53 54 echo '</div>'; 55 ?> 56 </html>