survey_seahorse

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

commit 588d9f578890eb1c0ab9707e8976fc1a41f7402e
parent 4cd61e072b2ea53e78f57a6fa20289b299212965
Author: John Kubach <johnkubach@gmail.com>
Date:   Mon, 10 Dec 2018 20:01:24 -0500

Implement block status to take survey page

Diffstat:
Mwebsite/index.php | 18++++++++++++++++++
Mwebsite/logout.php | 4+++-
Mwebsite/res/login-user.php | 1+
Mwebsite/res/register.php | 4+---
Mwebsite/takesurvey.php | 15++++++++++++++-
5 files changed, 37 insertions(+), 5 deletions(-)

diff --git a/website/index.php b/website/index.php @@ -15,3 +15,21 @@ $q = mysqli_fetch_assoc($result); <a href="createsurvey.php"> Create Survey </a> <br> <a href="findsurvey.php"> Find a Survey </a> <br> <a href="logout.php"> Logout </a> <br> + +<?php +if (isset($_SESSION['uid'])) { + $uid = $_SESSION['uid']; + $adminsql = "SELECT * FROM user WHERE admin=1 and user_id=$uid;"; + $result = mysqli_query($connect, $adminsql); + $check = mysqli_num_rows($result); + + + if ($check < 1) { + exit(); + } else { + $_SESSION['admin'] = 1; + echo "<a href='controlpanel.php'> Admin Control Panel </a> <br>"; + } +} + + diff --git a/website/logout.php b/website/logout.php @@ -4,5 +4,7 @@ unset($_SESSION["uid"]); unset($_SESSION["email"]); unset($_SESSION["username"]); unset($_SESSION["date"]); -header("Location: login.php"); +unset($_SESSION['admin']); +unset($_SESSION['blocked']); +header("Location: index.php"); ?> diff --git a/website/res/login-user.php b/website/res/login-user.php @@ -31,6 +31,7 @@ if (isset($_POST['submit'])) { $_SESSION['email'] = $row['email']; $_SESSION['username'] = $row['username']; $_SESSION['date'] = $row['registration_date']; + $_SESSION['blocked'] = ord($row['blocked']); header("Location: ../index.php?login=success"); exit(); } diff --git a/website/res/register.php b/website/res/register.php @@ -4,7 +4,6 @@ error_reporting(E_ALL | E_STRICT); if (isset($_POST['submit'])) { include_once '../config.php'; - $email = mysqli_real_escape_string($connect, $_POST['email']); $username = mysqli_real_escape_string($connect, $_POST['username']); $password = mysqli_real_escape_string($connect, $_POST['password']); @@ -39,8 +38,7 @@ if (isset($_POST['submit'])) { } } else { - header("Location: ../signup.php"); + header("Location: ../profile.php"); exit(); } - ?> diff --git a/website/takesurvey.php b/website/takesurvey.php @@ -5,6 +5,7 @@ error_reporting(E_ALL | E_STRICT); session_start(); include_once 'config.php'; +$block = $_SESSION['blocked']; $code = mysqli_real_escape_string($connect, $_POST['survey-code']); if (empty($code)) { @@ -18,7 +19,10 @@ if (empty($code)) { if ($check < 1) { header("Location: ../findsurvey.php?find=error"); exit(); - } else { + } elseif ($block == 50 || $block == 51) { + header("Location: res/nope.php"); + exit(); + }else { $row = mysqli_fetch_assoc($result); $_SESSION['sid'] = $row['survey_id']; $sid = $row['survey_id']; @@ -55,3 +59,12 @@ if (empty($code)) { ?> +<script> +var slider = document.getElementById("answerSlide"); +var output = document.getElementById("demo"); +output.innerHTML = slider.value; + +slider.oninput = function() { + output.innerHTML = this.value; +} +</script>