Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- session_start();
- $conn = mysqli_connect("localhost","workshe3_test","cats8000","workshe3_test");
- $message="";
- if(!empty($_POST["login"])) {
- $result = mysqli_query($conn,"SELECT * FROM Login WHERE User='" . $_POST["User"] . "' and Pass = '". $_POST["Pass"]."'");
- $row = mysqli_fetch_array($result);
- if(is_array($row)) {
- $_SESSION["ID"] = $row['ID'];
- $_SESSION["UserN"] = $row['User'];
- } else {
- $message = "Invalid Username or Password!";
- }
- }
- if(!empty($_POST["logout"])) {
- $_SESSION["ID"] = "";
- session_destroy();
- }
- ?>
- <html>
- <head>
- <title>User Login</title>
- <style>
- .field-group {
- margin:15px 0px;
- }
- .input-field {
- padding: 8px;width: 200px;
- border: #A3C3E7 1px solid;
- border-radius: 4px;
- }
- .form-submit-button {
- background: #808080;
- border: 0;
- padding: 8px 20px;
- border-radius: 4px;
- color: #FFF;
- text-transform: uppercase;
- }
- .logout-button {
- color: #09F;
- text-decoration: none;
- background: none;
- border: none;
- padding: 0px;
- cursor: pointer;
- }
- * {
- box-sizing: border-box;
- }
- .menu {
- float:left;
- width:20%;
- text-align:center;
- }
- .menu2 {
- float:left;
- width:20%;
- text-align:center;
- }
- .menuitem {
- background-color:#808080;
- color:white;
- padding:8px;
- margin-top:7px;
- }
- .main {
- float:left;
- width:60%;
- padding:0 20px;
- }
- .right {
- background-color:#808080;
- float:left;
- width:20%;
- padding:15px;
- margin-top:7px;
- text-align:center;
- }
- .fontsize{
- font-size:16px;
- }
- @media only screen and (max-width:620px) {
- .menu2, .main, .right {
- width:100%;
- }
- }
- </style>
- </head>
- <body>
- <div>
- <div style="display:block;margin:0px auto;">
- <?php if(empty($_SESSION["ID"])) { ?>
- <div style="background-color:#808080;padding:15px;text-align:center;">
- <img style="padding:8px;margin-top:7px;margin-right: 85%;" src="newerone.png" width="181" height="71" />
- </div>
- <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>
- <form style="margin-top:2%;" method="post" id="frmLogin">
- <div class="error-message"><?php if(isset($message)) { echo $message; } ?></div>
- <h2 style="font-size: 18px;"> Login</h2>
- <?php
- //CHECKING IF USER CREATED A THREAD. IF SO ECHO SUBMITTED.
- if (isset($_GET['msg']) )
- {
- $echothread = $_GET['msg'];
- echo $echothread . "<br>";
- "<br>";
- }
- ?>
- <div class="field-group">
- <div><label for="login">Username</label></div>
- <div><input name="User" type="text" class="input-field"></div>
- </div>
- <div class="field-group">
- <div><label for="password">Password</label></div>
- <div><input name="Pass" type="password" class="input-field"> </div>
- </div>
- <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>
- <div class="field-group">
- <div><input type="submit" name="login" value="Login" class="form-submit-button"></span></div>
- </div>
- </form> <div style="background-color:#808080;padding:55px;text-align:center;margin-top: 20%;">
- </div>
- <?php
- } else {
- $result = mysqlI_query($conn,"SELECT * FROM Login WHERE User='" . $_SESSION["ID"] . "'");
- $row = mysqli_fetch_array($result);
- ?>
- <form action="" method="post" id="frmLogout">
- <!-- START OF SITE!-->
- <div style="background-color:#808080;padding:15px;text-align:center;">
- <img style="padding:8px;margin-top:7px;margin-right: 85%;" src="newerone.png" width="181" height="71" />
- </div>
- <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>
- <body style="font-family:Verdana;color:#aaaaaa;">
- <div style="overflow:auto;">
- <div class="main">
- <h2 style="font-size: 18px;">Welcome, <?php echo $_SESSION["UserN"]?>! </h2>
- <?php
- //CHECKING IF USER CREATED A THREAD. IF SO ECHO SUBMITTED.
- if (isset($_GET['sub']) )
- {
- $echothread = $_GET['sub'];
- echo $echothread . "<br>";
- "<br>";
- }
- ?>
- <?php
- $servername = "localhost";
- $username = "workshe3_test";
- $password = "cats8000";
- $dbname = "workshe3_test";
- $conn = new mysqli($servername, $username, $password, $dbname);
- if ($conn->connect_error) {
- die("Connection failed: " . $conn->connect_error);
- }
- $sql = "SELECT * FROM Threads, Login WHERE Login.ID=Threads.ID ORDER BY Threads.ThreadID DESC";
- $result = $conn->query($sql);
- if ($result->num_rows > 0) {
- while($row = $result->fetch_assoc()) {
- $ineedthis[] = $row['ID'];
- $testing = $row['ThreadID'];
- 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>";
- }
- } else {
- echo "0 results";
- }
- $conn->close();
- ?>
- </div>
- <br>
- <div class="menu" style="margin-left: 19%;outline-style: solid;margin-bottom: 10px;font-size:14px;">
- <a href="login.php" style="text-decoration: none;"> <div class="menuitem">Home</div></a>
- <a href="accountoverview.php" style="text-decoration: none;"><div class="menuitem"><?php echo $_SESSION['UserN'] ?>'s Account</div></a>
- <a href="makepost.php" style="text-decoration: none;"> <div class="menuitem">New Thread</div></a>
- <a href="logout.php" style="text-decoration:none;"> <div class="menuitem">Logout</div></a>
- <h1 style="font-size:18px;"> Moderators:</h1>
- <h2 style="font-size:18px;"> Josh</h2>
- <p style="text-align: center;"> 906 Cringers Online<img src="online.png" width="15" height="15" style="float: left;"/></p>
- </div>
- </form>
- </div>
- </div>
- <?php } ?>
- </body></html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement