Advertisement
ProToTN

Untitled

Oct 20th, 2017
87
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 3.96 KB | None | 0 0
  1. <?php
  2. // Utility stuff
  3. error_reporting(E_ALL);
  4. ini_set('display_errors', 'On');
  5. session_start();
  6.  
  7. $loggedIn = isset($_SESSION['login_username']);
  8.  
  9. if (!$loggedIn) {
  10.     header("Location: ../index.php?action=login");
  11.     die("Website doesn't work apparantely if you dare ignore headers");
  12. }
  13.  
  14.  
  15. $action = "";
  16.  
  17. if (isset($_GET['action'])) {
  18.     $action = $_GET['action'];
  19. } else {
  20.     $action = "index";
  21. }
  22. ?>
  23.  
  24. <head>
  25.     <link rel="stylesheet" type="text/css" href="index.css">
  26.     <title>ProTo's website - Loup (<?php echo strtoupper($action); ?>)</title>
  27. </head>
  28.  
  29. <body>
  30. <?php
  31.     if ($action == "index") {
  32.     echo '
  33.         <form class="login-form" method="POST" action="">
  34.             <div class="login-page">
  35.                 <div class="tble form">
  36.                     <form class="login-form" method="POST" action="XXXX.php">
  37.                         <table>
  38.                             <tr>
  39.                                 <th></th>
  40.                                 <th>Role Name</th>
  41.                                 <th>Description</th>
  42.                             </tr>
  43.                         ';
  44.         $loginName = base64_decode($_SESSION['login_username']);
  45.         $conn = new mysqli("localhost", "proto_proto", "12351235", "proto_maindb");
  46.         $sql = "SELECT * FROM loup_roles
  47.         WHERE account = '$loginName'";
  48.         echo '<p>Hey '.base64_decode($_SESSION['login_username']).'!</p>';
  49.         $result = $conn->query($sql);
  50.         if ($result->num_rows > 0) {
  51.             while ($row = $result->fetch_assoc()) {
  52.                 echo "<tr><td><input type='checkbox' name='checkedRoles[]' value='selected'><br></td><td>".$row['nom']."</td><td>".$row['description']."</td></tr>";
  53.             }
  54.         }
  55.         echo '             
  56.                         </table>
  57.                         <br><br>
  58.                         <br><br>
  59.                         <table>
  60.                             <tr>
  61.                                 <th></th>
  62.                                 <th>Player Name</th>
  63.                             </tr>
  64.         ';
  65.         $sql = "SELECT * FROM loup_players
  66.         WHERE account = '$loginName'";
  67.         $result = $conn->query($sql);
  68.         if ($result->num_rows > 0) {
  69.             $results_array = array();
  70.             while ($row = $result->fetch_assoc()) {
  71.                 echo "<tr><td><input type='checkbox' name='checkedPlayers[]' value='selected'><br></td><td>".$row['nom']."</td></tr>";
  72.             }
  73.         }
  74.         echo'
  75.                         </table>
  76.                         <br><br>
  77.                         <button name="pick">Pick</button><br><br>
  78.                         <button name="delete">Delete</button>
  79.                         ';
  80.                         if (isset($_SESSION['msg'])){
  81.                             echo '<p>'.$_SESSION['msg'].'</p>';
  82.                             //$_SESSION['msg'] = "";
  83.                         }else {echo'hi';}
  84.         echo'
  85.                     </form>
  86.                 </div>
  87.             </div>
  88.         </form>';
  89.        
  90.         $_SESSION["TEST"] = "Test";
  91.         if (isset($_POST["delete"]) == 1){
  92.             if (isset($_POST['checkedRoles']) && isset($_POST['checkedPlayers'])){
  93.                 $checkedRolesArray = $_POST['checkedRoles'];
  94.                 $checkedPlayersArray = $_POST['checkedPlayers'];
  95.                 if (count($checkedRolesArray) != count($checkedPlayersArray)){
  96.                     $_SESSION['msg'] = "<br><br>ERROR: Number of checked roles should be equal to the number of checked players!";
  97.                 }else{
  98.                     header("Location: ../loup/delete.php");
  99.                 }
  100.             }
  101.         }
  102.         else if (isset($_POST["pick"]) == 1){
  103.             header("Location: ../loup/pick.php");
  104.         }
  105.  
  106.         echo'
  107.         <div class="login-page">
  108.                 <div class="form">
  109.                     <form class="login-form" method="POST" action="addrole.php">
  110.                         <input type="text" id="T1" name="T1" placeholder="Role name">                  
  111.                         <textarea name="T2" id="textarea" cols="35" placeholder="Enter description here (optional)"></textarea>
  112.                         <br>
  113.                         <br>
  114.                         <br>
  115.                         <button>Add role</button>
  116.                         ';
  117.                         if (isset($_SESSION['message_paste'])) {
  118.                             echo '<br><p>'.$_SESSION['message_paste'].'</p>';
  119.                             unset($_SESSION['message_paste']);
  120.                         }
  121.     echo '
  122.  
  123.                     </form>
  124.                 </div>
  125.             </div>
  126.  
  127.  
  128.         <div class="login-page">
  129.             <div class="form">
  130.                 <form class="login-form" method="POST" action="addplayer.php">
  131.                     <input type="text" id="T1" name="T1" placeholder="Player name">
  132.                     <br>
  133.                     <br>
  134.                     <br>
  135.                     <button>Add player</button>
  136.                     ';
  137.                     if (isset($_SESSION['message_paste'])) {
  138.                         echo '<br><p>'.$_SESSION['message_paste'].'</p>';
  139.                         unset($_SESSION['message_paste']);
  140.                     }
  141.     echo'
  142.                 </form>
  143.             </div>
  144.         </div>';
  145.         }
  146.     ?>
  147. </body>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement