survey_seahorse

Software Engineering Project - Fall 2018
Log | Files | Refs | README

index.php (2380B)


      1 <?php
      2 include_once 'res/session.php';
      3 include_once 'config.php';
      4 $sql = "SELECT question_content FROM question ORDER BY RAND() LIMIT 1;";
      5 $result = mysqli_query($connect, $sql) or die(mysqli_error($connect));
      6 $q = mysqli_fetch_assoc($result);
      7 $sql = "select * from user order by registration_date desc limit 1;";
      8 $result = mysqli_query($connect, $sql) or die(mysqli_error($connect));
      9 $newUser = mysqli_fetch_assoc($result);
     10 
     11 ?>
     12 <head>
     13 <title>Survey Seahorse</title>
     14 
     15 <link rel="apple-touch-icon" sizes="180x180" href="res/img/fav/apple-touch-icon.png">
     16 <link rel="icon" type="image/png" sizes="32x32" href="res/img/fav/favicon-32x32.png">
     17 <link rel="icon" type="image/png" sizes="16x16" href="res/img/fav/favicon-16x16.png">
     18 <link rel="manifest" href="res/img/fav/site.webmanifest">
     19 <link rel="mask-icon" href="res/img/fav/safari-pinned-tab.svg" color="#5bbad5">
     20 <meta name="msapplication-TileColor" content="#da532c">
     21 <meta name="theme-color" content="#ffffff">
     22 <link rel="stylesheet" href="res/style.css">
     23 </head>
     24 
     25 <?php 
     26 include 'res/navbar.php';
     27 include 'res/txt/msg.php';
     28 if (isset($message)) {
     29     echo "<center ><h3> Message from the Admins: ",  $message, "</h3> </center>";
     30 }
     31 ?>
     32 <div class="panel">
     33     <h1> Survey Seahorse </h1>
     34     <h3> Random Question: <?php echo $q['question_content']; ?>
     35     <img src="res/img/seahorse.png" class="seahorse_pic" size="250">
     36     <h3> Welcome to our newest user: <?php echo $newUser['username']; ?> </h3>
     37 </div>
     38 
     39 <div class="index-grid-panel">
     40     <a href="login.php">Login</a>
     41     <a href="signup.php">Register</a>
     42     <!--<a href="profile.php"> Profile </a> <br>
     43     <a href="createsurvey.php"> Create Survey </a> <br>-->
     44     <a href="findsurvey.php">Find a Survey</a>
     45     <a href="directory.php">Survey Directory</a>
     46     <a href="archive.php">Survey Archive</a>
     47     <a href="about.php">About</a>
     48 
     49 <?php 
     50 if (isset($_SESSION['uid'])) {
     51     $uid = $_SESSION['uid'];
     52     $adminsql = "SELECT * FROM user WHERE admin=1 and user_id=$uid;";
     53     $result = mysqli_query($connect, $adminsql);
     54     $check = mysqli_num_rows($result);
     55 
     56 
     57     if ($check < 1) {
     58         echo "<a class='off' href='logout.php'> Logout </a>";
     59         exit();
     60     } else {
     61         $_SESSION['admin'] = 1;
     62         echo "<a href='controlpanel.php'> Admin Control Panel </a> <br>";
     63         echo "<a class='off' href='logout.php'> Logout </a>";
     64     }
     65 }
     66 exit();
     67 ?>
     68 
     69 </div>