Advertisement
Guest User

Untitled

a guest
Dec 8th, 2017
120
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 5.88 KB | None | 0 0
  1. <?php
  2. session_start();
  3. $conn = mysqli_connect("localhost","workshe3_test","cats8000","workshe3_test");
  4.  
  5. $message="";
  6. if(!empty($_POST["login"])) {
  7. $result = mysqli_query($conn,"SELECT * FROM Login WHERE User='" . $_POST["User"] . "' and Pass = '". $_POST["Pass"]."'");
  8. $row = mysqli_fetch_array($result);
  9. if(is_array($row)) {
  10. $_SESSION["ID"] = $row['ID'];
  11. $_SESSION["UserN"] = $row['User'];
  12. } else {
  13. $message = "Invalid Username or Password!";
  14. }
  15. }
  16. if(!empty($_POST["logout"])) {
  17. $_SESSION["ID"] = "";
  18. session_destroy();
  19. }
  20. ?>
  21. <html>
  22. <head>
  23. <title>User Login</title>
  24. <style>
  25.  
  26. .field-group {
  27. margin:15px 0px;
  28. }
  29. .input-field {
  30. padding: 8px;width: 200px;
  31. border: #A3C3E7 1px solid;
  32. border-radius: 4px;
  33. }
  34. .form-submit-button {
  35. background: #808080;
  36. border: 0;
  37. padding: 8px 20px;
  38. border-radius: 4px;
  39. color: #FFF;
  40. text-transform: uppercase;
  41. }
  42. .logout-button {
  43. color: #09F;
  44. text-decoration: none;
  45. background: none;
  46. border: none;
  47. padding: 0px;
  48. cursor: pointer;
  49. }
  50. * {
  51. box-sizing: border-box;
  52. }
  53. .menu {
  54. float:left;
  55. width:20%;
  56. text-align:center;
  57.  
  58. }
  59. .menu2 {
  60. float:left;
  61. width:20%;
  62. text-align:center;
  63. }
  64. .menuitem {
  65. background-color:#808080;
  66. color:white;
  67. padding:8px;
  68. margin-top:7px;
  69.  
  70. }
  71.  
  72. .main {
  73. float:left;
  74. width:60%;
  75. padding:0 20px;
  76. }
  77. .right {
  78. background-color:#808080;
  79. float:left;
  80. width:20%;
  81. padding:15px;
  82. margin-top:7px;
  83. text-align:center;
  84. }
  85. .fontsize{
  86. font-size:16px;
  87. }
  88.  
  89. @media only screen and (max-width:620px) {
  90. .menu2, .main, .right {
  91. width:100%;
  92. }
  93. }
  94.  
  95. </style>
  96. </head>
  97. <body>
  98. <div>
  99. <div style="display:block;margin:0px auto;">
  100. <?php if(empty($_SESSION["ID"])) { ?>
  101. <div style="background-color:#808080;padding:15px;text-align:center;">
  102. <img style="padding:8px;margin-top:7px;margin-right: 85%;" src="newerone.png" width="181" height="71" />
  103. </div>
  104. <div style="font-family:Verdana; color: white;background-color:#808080;padding:15px;margin-top: 10px;font-size:14px;"> SUBREDDITS ^ NEWS - ASKITRED - CRINGE - THE_DONALD - FUNNY - IAMA - SHOWERTHOUGHTS - FIFTYFIFTY </div>
  105. <form style="margin-top:2%;" method="post" id="frmLogin">
  106. <div class="error-message"><?php if(isset($message)) { echo $message; } ?></div>
  107. <h2 style="font-size: 18px;"> Login</h2>
  108.  
  109. <?php
  110. //CHECKING IF USER CREATED A THREAD. IF SO ECHO SUBMITTED.
  111. if (isset($_GET['msg']) )
  112. {
  113. $echothread = $_GET['msg'];
  114. echo $echothread . "<br>";
  115. "<br>";
  116. }
  117. ?>
  118.  
  119. <div class="field-group">
  120. <div><label for="login">Username</label></div>
  121. <div><input name="User" type="text" class="input-field"></div>
  122. </div>
  123. <div class="field-group">
  124. <div><label for="password">Password</label></div>
  125. <div><input name="Pass" type="password" class="input-field"> </div>
  126. </div>
  127. <h4 style="font-size: 18px;"> Need an account? <a href="http://southstark.org/PSD/Lombardi/Reddit/createa.php">Click here</a> to sign up.</h4>
  128. <div class="field-group">
  129. <div><input type="submit" name="login" value="Login" class="form-submit-button"></span></div>
  130. </div>
  131. </form> <div style="background-color:#808080;padding:55px;text-align:center;margin-top: 20%;">
  132. </div>
  133. <?php
  134.  
  135. } else {
  136. $result = mysqlI_query($conn,"SELECT * FROM Login WHERE User='" . $_SESSION["ID"] . "'");
  137. $row = mysqli_fetch_array($result);
  138. ?>
  139. <form action="" method="post" id="frmLogout">
  140. <!-- START OF SITE!-->
  141. <div style="background-color:#808080;padding:15px;text-align:center;">
  142. <img style="padding:8px;margin-top:7px;margin-right: 85%;" src="newerone.png" width="181" height="71" />
  143. </div>
  144. <div style="font-family:Verdana; color: white;background-color:#808080;padding:15px;margin-top: 10px;font-size:14px;"> SUBREDDITS ^ NEWS - ASKITRED - CRINGE - THE_DONALD - FUNNY - IAMA - SHOWERTHOUGHTS - FIFTYFIFTY </div>
  145. <body style="font-family:Verdana;color:#aaaaaa;">
  146. <div style="overflow:auto;">
  147. <div class="main">
  148. <h2 style="font-size: 18px;">Welcome, <?php echo $_SESSION["UserN"]?>! </h2>
  149.  
  150. <?php
  151. //CHECKING IF USER CREATED A THREAD. IF SO ECHO SUBMITTED.
  152. if (isset($_GET['sub']) )
  153. {
  154. $echothread = $_GET['sub'];
  155. echo $echothread . "<br>";
  156. "<br>";
  157. }
  158. ?>
  159. <?php
  160. $servername = "localhost";
  161. $username = "workshe3_test";
  162. $password = "cats8000";
  163. $dbname = "workshe3_test";
  164.  
  165.  
  166. $conn = new mysqli($servername, $username, $password, $dbname);
  167.  
  168. if ($conn->connect_error) {
  169. die("Connection failed: " . $conn->connect_error);
  170. }
  171.  
  172. $sql = "SELECT * FROM Threads, Login WHERE Login.ID=Threads.ID ORDER BY Threads.ThreadID DESC";
  173. $result = $conn->query($sql);
  174. if ($result->num_rows > 0) {
  175.  
  176. while($row = $result->fetch_assoc()) {
  177. $ineedthis[] = $row['ID'];
  178. $testing = $row['ThreadID'];
  179. echo "<br><div class='fontsize' style='outline-style: solid;'> <br> <div style='font-weight: bold;'> " .$row["Name"]. "</div>" ."Submitted by ". $row["User"]. "<br><a href='posts.php?thID=$testing' > <h1 style='color: black;font-size: 15px;'>View More</h1></a></div>";
  180. }
  181. } else {
  182. echo "0 results";
  183. }
  184. $conn->close();
  185. ?>
  186.  
  187. </div>
  188. <br>
  189. <div class="menu" style="margin-left: 19%;outline-style: solid;margin-bottom: 10px;font-size:14px;">
  190. <a href="login.php" style="text-decoration: none;"> <div class="menuitem">Home</div></a>
  191. <a href="accountoverview.php" style="text-decoration: none;"><div class="menuitem"><?php echo $_SESSION['UserN'] ?>'s Account</div></a>
  192. <a href="makepost.php" style="text-decoration: none;"> <div class="menuitem">New Thread</div></a>
  193. <a href="logout.php" style="text-decoration:none;"> <div class="menuitem">Logout</div></a>
  194. <h1 style="font-size:18px;"> Moderators:</h1>
  195. <h2 style="font-size:18px;"> Josh</h2>
  196. <p style="text-align: center;"> 906 Cringers Online<img src="online.png" width="15" height="15" style="float: left;"/></p>
  197.  
  198.  
  199. </div>
  200.  
  201.  
  202. </form>
  203. </div>
  204. </div>
  205. <?php } ?>
  206. </body></html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement