Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <!DOCTYPE HTML>
- <HTML>
- <HEAD>
- <!--NOTE: FIX LOGOUT BUTTON-->
- <meta name="viewport" content="width=device-width, initial-scale=1">
- <title>Bedan Kiosk</title>
- <link rel="stylesheet" href="css/css_dashboard.css">
- <link rel="stylesheet" href="css/css_mainnav.css">
- <link rel="stylesheet" href="css/css_datatable.css">
- </HEAD>
- <script>
- // Get the modal
- var modal = document.getElementById('id01');
- // Get the <span> element that closes the modal
- var span = document.getElementsByClassName("close")[0];
- // When the user clicks anywhere outside of the modal, close it
- window.onclick = function(event) {
- if (event.target == modal) {
- modal.style.display = "none";
- }
- }
- </script>
- <style>
- table {
- width: 100%;
- }
- Table tr > *:nth-child(1) {
- display: none;
- }
- Table tr > *:nth-child(3) {
- display: none;
- }
- Table tr > *:nth-child(4) {
- display: none;
- }
- Table tr > *:nth-child(5) {
- display: none;
- }
- Table tr > *:nth-child(6) {
- display: none;
- }
- Table tr > *:nth-child(7) {
- display: none;
- }
- Table tr > *:nth-child(8) {
- display: none;
- }
- </style>
- <BODY onload="makeTableScroll();">
- <?php
- session_start();
- include "Connect.php";
- if(!empty($_SESSION['username'])){
- $db_login = $_SESSION['username'];
- }
- else{
- $db_login =null;
- }
- $view_query = mysqli_query($connections, "select * from tblusers where Username = '$db_login' ");
- while($row = mysqli_fetch_assoc($view_query)){
- $db_login = $row["Username"];
- }
- if($db_login == null){
- $_SESSION['username'] = 'Logged-out!';
- }
- ?>
- <img style="height: auto; width: 40%; position:absolute; z-index : -1;" src="img/top_bg.png"/>
- <nav id="main_nav">
- <a href="dashboard.html"> <img style="height: auto; width: 11%; margin:8px; margin-left:23px; float:left;" src="img/main_logo.png"/> </a>
- <ul>
- <a onclick="logout()" style='text-decoration:none; cursor: pointer; <?php
- if(isset($_SESSION['username'])){
- if($_SESSION['username'] == 'Logged-out!' || empty($_SESSION['username'])){
- echo 'visibility: hidden;';
- }
- }?>'><li class="item">LOG OUT</li></a>
- <a onclick="document.getElementById('id01').style.display='block'" style='text-decoration:none; cursor: pointer; <?php
- if(isset($_SESSION['username'])){
- if($_SESSION['username'] != 'Logged-out!'){
- echo 'visibility: hidden;';
- }
- }?>'><li class="item">LOG IN</li></a>
- <a href='<?php
- if(isset($_SESSION['Role'])){
- if($_SESSION['Role'] == 'Logged-out!'){
- echo 'Dashboard.php';
- }
- else{
- echo 'Forum.php';
- }
- }
- ?>' style="text-decoration:none"><li class="item">FORUMS</li></a>
- <a href='<?php
- if(isset($_SESSION['Role'])){
- if($_SESSION['Role'] == 'Member'){
- echo 'Member.php';
- }
- else if($_SESSION['Role'] == 'Admin'){
- echo 'Admin.php';
- }
- else{
- echo 'Dashboard.php';
- }
- }
- ?>' style="text-decoration:none"><li class="item">GUARDHOUSE</li></a>
- <a href="Dashboard.php" style="text-decoration:none"><li class="item">HOME</li></a>
- </ul>
- </nav>
- <div id="form_login" style='
- <?php
- if(isset($_SESSION['username'])){
- if($_SESSION['username'] != 'Logged-out!'){
- echo 'visibility: hidden;';
- }
- }?>'>
- <div id="id01" class="modal">
- <form class="modal-content animate" action="<?php echo htmlspecialchars($_SERVER['PHP_SELF']); ?>" method="POST">
- <div class="imgcontainer">
- <span onclick="document.getElementById('id01').style.display='none'" class="close">×</span>
- </div>
- <div class="container">
- <label for="uname"><b>Username</b></label>
- <input type="text" name="username" placeholder="Enter Your Name" required>
- <label for="psw"><b>Password</b></label>
- <input type="text" name="password" placeholder="Enter Your Password" required>
- <button type="submit" name="bttnLogin">Login</button>
- <label>
- <input type="checkbox" checked="checked" name="remember"> Remember me
- </label>
- </div>
- <div class="container" style="background-color:#f1f1f1">
- <span class="psw"><a href="#">Forgot password?</a></span>
- </div>
- </form>
- </div>
- </div>
- <div id="form_logout" style='<?php if(isset($_SESSION['username'])){
- if($_SESSION['username'] == '' || $_SESSION['username'] == 'Logged-out!'){
- echo 'visibility: hidden;';
- }
- }?>'>
- <form action="<?php echo htmlspecialchars($_SERVER['PHP_SELF']); ?>" method="POST">
- <input type="submit" class="button" value="LOG OUT" name="bttnLogout"> <br>
- </form>
- </div>
- <?php
- if(isset($_SESSION['username'])){
- echo $_SESSION['username'];
- }
- //login account
- if(isset($_POST['bttnLogin'])){
- require 'Connect.php';
- $username = $_POST["username"];
- $password = $_POST["password"];
- //getting entry
- $result = mysqli_query($connections, "SELECT * FROM `tblusers` WHERE username ='$username' and password = '$password'");
- //role checking
- if(mysqli_num_rows($result) == 1){
- $_SESSION['username'] = $username;
- $admin = mysqli_query($connections, "SELECT * FROM `tblusers` WHERE username ='$username' and role ='Admin'");
- $member = mysqli_query($connections, "SELECT * FROM `tblusers` WHERE username ='$username' and role ='Member'");
- $student = mysqli_query($connections, "SELECT * FROM `tblusers` WHERE username ='$username' and role ='Student'");
- $author = mysqli_query($connections, "SELECT * FROM `tblusers` WHERE username ='$username' and role ='Author'");
- $moderator = mysqli_query($connections, "SELECT * FROM `tblusers` WHERE username ='$username' and role ='Moderator'");
- $user = mysqli_query($connections, "SELECT * FROM `tblusers` WHERE username ='$username' and role ='User'");
- //admin
- if(mysqli_num_rows($admin) == 1){ header('location: Admin.php');
- $_SESSION['Role'] = 'Admin';
- }
- //member
- else if(mysqli_num_rows($member) == 1){ header('location: Member.php');
- $_SESSION['Role'] = 'Member';
- }
- //Student
- else if(mysqli_num_rows($student) == 1){ header('location: Dashboard.php');
- $_SESSION['Role'] = 'Student';
- }
- //Author
- else if(mysqli_num_rows($author) == 1){ header('location: Author.php');
- $_SESSION['Role'] = 'Author';
- }
- //Moderator
- else if(mysqli_num_rows($moderator) == 1){ header('location: Dashboard.php');
- $_SESSION['Role'] = 'Moderator';
- }
- //User
- else if(mysqli_num_rows($moderator) == 1){ header('location: Dashboard.php');
- $_SESSION['Role'] = 'User';
- }
- //invalid role
- else{echo "<script language='javascript'> alert('Account invalid!')</script>";}
- }
- else{echo "<script language='javascript'> alert('Account invalid!')</script>";}
- }
- ?>
- <div id="dashboard_main">
- <div id="article_menu">
- <?php
- include 'Connect.php';
- $view_query = mysqli_query($connections, "select * from tblnews limit 6");
- echo '<div class="scrollingTable">';
- echo "<br><table border='1' width='60%' id='table'>";
- echo "<tr>";
- echo "<td>ArticleID</td>";
- echo "<td><img style='height: auto; width: 93%; margin:10px;' src='img/article_head.png'/></td>";
- echo "<td>Author</td>";
- echo "<td>Date</td>";
- echo "<td>Content</td>";
- echo "<td>Photographer</td>";
- echo "<td>PhotoID</td>";
- echo "<td></td>";
- echo "</tr>";
- echo "<tr>";
- echo "<td></td>";
- echo "</tr>";
- //while loop for table
- while($row = mysqli_fetch_assoc($view_query)){
- $db_article = $row["ArticleID"];
- $db_title = $row["Title"];
- $db_author = $row["Author"];
- $db_date = $row["Date"];
- $db_content = $row["Content"];
- $db_photographer = $row["Photographer"];
- $db_photo = $row["PhotoID"];
- $photo = "";
- $photo2 = "";
- //can be removed later
- if(empty($db_photo)){
- $photo = "Empty";
- }
- else{$photo = "<img src='uploads/$db_photo' style='width: 100px;'>";
- $photo2 = "uploads/$db_photo";
- }
- echo "<tr>
- <td>$db_article</td>
- <td>$db_title</td>
- <td>$db_author</td>
- <td>$db_date</td>
- <td>$db_content</td>
- <td>$db_photographer</td>
- <td>$photo</td>
- <td>$photo2</td>
- </tr>";
- }
- echo "<tr>
- <td></td>
- <td></td>
- </tr>";
- echo "</table>";
- echo "</div>";
- echo '<a href="News.php"><button>View all</button></a>';
- echo "<script></script>";
- echo "<br>";
- ?>
- </div>
- <div id="carousel_main">
- Title <input type="text" name="username" id="title" readonly><br>
- Author <input type="text" name="username" id="author" readonly><br>
- Date <input type="text" name="username" id="date" readonly><br>
- <textarea rows="4" cols="50" id="content" readonly>
- </textarea><br>
- <img src='uploads/sanbeda.png' style='width: 300px;' id="articlepic">
- </div>
- </div>
- <img style="height: auto; width: 15%; position: relative; float:right;transform: scaleX(-1); top:4px;" src="img/foot_trans.png"/>
- <img style="height: auto; width: 15%; position: relative; margin:0 auto; top:4px;" src="img/foot_trans.png"/>
- <footer id="main_footer">
- <img style="height: auto; width: 20%; vertical-align:middle; float:left; margin-top:55px; margin-left:30px;" src="img/sub_logo.png"/>
- <h3>Back-End Programmer</h3>
- <hr style="width: 290px;" align="left">
- <span>Vince Ryan Bufete</span>
- <footer id="copyright">
- © Team Variabois 2018 - 2019. All Rights Reserved
- </footer>
- </footer>
- <script>
- <!--MAIN SCRIPT FOR CLIENT-SIDE FUNCTIONALITY-->
- <span id="spnText"></span>
- <script src="jquery.min.js"></script>
- <script>
- //JAVASCRIPT FOR MAKING TABLE SCROLLABLE
- var maxRows;
- function makeTableScroll() {
- // Constant retrieved from server-side via JSP
- maxRows = 9;
- var table = document.getElementById('table');
- var wrapper = table.parentNode;
- var rowsInTable = table.rows.length;
- var height = 50;
- if (rowsInTable > maxRows) {
- for (var i = 0; i < maxRows; i++) {
- height += table.rows[i].clientHeight;
- }
- wrapper.style.height = height + "px";
- }
- }
- function myFunction() {
- maxRows = 3;
- }
- var table = document.getElementById('table'),rIndex;
- var picture;
- //CLICKABLE TABLE
- for (var i = 0; i < table.rows.length; i++){
- if(i!=0){
- table.rows[i].onclick = function()
- {
- this.name = document.getElementById("title").value = this.cells[1].innerHTML;
- this.role = document.getElementById("author").value = this.cells[2].innerHTML;
- this.email = document.getElementById("date").value =
- this.cells[3].innerHTML;
- this.password = document.getElementById("content").value =
- this.cells[4].innerHTML;
- var picture = this.cells[7].innerHTML;
- this.student = document.getElementById("articlepic").src = picture;
- if(typeof rIndex !== "undefined"){
- table.rows[rIndex].classList.toggle("highlight");
- }
- rIndex = this.rowIndex;
- this.classList.toggle("highlight");
- //shorter form of code above, without textbox dependency. Just gets the values from the cells
- /* this.name = this.cells[0].innerHTML;
- this.age = this.cells[1].innerHTML;
- this.country = this.cells[2].innerHTML;
- alert(this.name + ", " + this.age + ", " + this.country);
- */
- }
- }
- }
- function logout(){
- window.location.href='Logout.php';
- }
- </script>
- </BODY>
- </HTML>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement