Advertisement
Guest User

Untitled

a guest
Jul 25th, 2018
142
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 2.79 KB | None | 0 0
  1. <?php
  2. session_start();
  3.  
  4. $servername = "localhost";
  5. $dbusername = "root";
  6. $dbpassword = "";
  7. $dbname = "d4n13ls";
  8.  
  9. $conn = mysqli_connect($servername, $dbusername, $dbpassword, $dbname);
  10.  
  11. if(!$conn) {
  12.     die("Connection failed: " . mysqli_connect_error());
  13. }
  14.  
  15. if($_SERVER["REQUEST_METHOD"] == "POST"){
  16. if(isset($_POST["username"])) {
  17.  
  18.     $username = $_POST["username"];
  19.  
  20.     $password = $_POST["password"];
  21.  
  22.     $password = password_hash($password, PASSWORD_DEFAULT);
  23.  
  24.  
  25.     $query = "SELECT username and password FROM members WHERE username=$username AND password=$password";
  26.     if($result = mysqli_query($conn, $query)) {
  27.     $rows = mysqli_num_rows($result);
  28.     if($rows["username"] == $username && $rows["password"] == $password) {
  29.         $_SESSION["username"] = $username;
  30.         $_SESSION["user_id"] = $rows["id"];
  31.         header("location: home.php");
  32.     }
  33. }
  34. }
  35. }
  36. ?>
  37.  
  38.  
  39.  
  40.  
  41.  
  42. <!DOCTYPE html>
  43. <html>
  44. <head>
  45.     <meta charset="UTF-8"/>
  46.     <title>D4N13LS</title>
  47.     <style>
  48.     * {
  49.     -webkit-user-select:none;
  50.     -moz-user-select:none;
  51.     -ms-user-select:none;
  52.     user-select:none;
  53.     font-family:monospace;
  54.     color:#d5ddf7;
  55. }
  56.  
  57. html {
  58.     height:100%;
  59.     margin:0;
  60.     padding:0;
  61. }
  62.  
  63. body {
  64.     max-height: 100%;
  65.     height:100%;
  66.     margin:0;
  67.     padding:0;
  68.     background-image:url("https://ak1.picdn.net/shutterstock/videos/25061711/thumb/11.jpg");
  69.     background-size:100% 100%;
  70.     background-repeat: no-repeat;
  71. }
  72. h2 {
  73. position:absolute;
  74. top:31%;
  75. left:7%;
  76. }
  77.  
  78. #Validate {
  79.     font-weight:bold;
  80.     font-size:140%;
  81.     position: absolute;
  82.     top:34%;
  83.     left:10%;
  84. }  
  85. input[type="text"], input[type="password"], textarea {
  86.   outline: none;
  87.   border: none;
  88.   background-color: rgba(0, 0, 0, 0);
  89.   border-bottom: 0.5px solid #d5ddf7;
  90.   color:#d5ddf7;
  91. }
  92. #username {
  93.     position: absolute;
  94.     top:42%;
  95.     left:13%;
  96.     width:15%;
  97.     height:3%;
  98. }
  99. #password {
  100.     position: absolute;
  101.     top:46.5%;
  102.     left:13%;
  103.     width:15%;
  104.     height:3%;
  105. }
  106.  
  107. button {
  108.     color:black;
  109.     background-color:#53aee6;
  110.     border:none;
  111.     font-weight: bold;
  112.     font-family:monospace;
  113.     -webkit-box-shadow: -1px -1px 19px 2px rgba(83,174,230,1);
  114.     -moz-box-shadow: -1px -1px 19px 2px rgba(83,174,230,1);
  115.     -ms-box-shadow: -1px -1px 19px 2px rgba(83,174,230,1);
  116.     box-shadow: -1px -1px 19px 2px rgba(83,174,230,1);
  117.     font-size:1em;
  118.     position: absolute;
  119.     top:52%;
  120.     left:23.5%;
  121. }
  122. button:hover {
  123.      cursor:pointer;
  124. }
  125. h2 {
  126.     font-size:150%;
  127. }
  128.  
  129. </style>
  130. </head>
  131. <body>
  132.     <div id="label">
  133. <h2>D4N13LS</h2>
  134. <p id="Validate">Validation</p>
  135. </div>
  136. <form action="<?php htmlspecialchars($_SERVER["PHP_SELF"]); ?>" method="post">
  137.     <input name="username" type="text" class="input" placeholder="Username" id="username" />
  138.     <input name="password" type="password" class="input" placeholder="Password" id="password" />
  139.     <button type="submit">Connect</button>
  140. </form>
  141. </body>
  142. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement