Advertisement
Guest User

Untitled

a guest
Jul 26th, 2016
72
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.93 KB | None | 0 0
  1. <?php
  2.  
  3. $servername = "localhost";
  4. $username = "root";
  5. $password = "";
  6. $dbname = "loginform";
  7.  
  8.  
  9. $conn = new mysqli($servername, $username, $password, $dbname);
  10.  
  11. if ($conn->connect_error) {
  12. die("Connection failed: " . $conn->connect_error);
  13. }
  14.  
  15.  
  16. if(isset($_POST['login'])){
  17. $username = $_POST['name'];
  18. $pass = $_POST['password'];
  19.  
  20.  
  21. $sql = "SELECT * FROM users WHERE name ='$username' AND password ='$pass' ";
  22.  
  23. $result = $conn->query($sql);
  24.  
  25.  
  26.  
  27. if ($result->num_rows > 0) {
  28. session_start();
  29.  
  30. echo 'esti logat';
  31. }
  32. }
  33.  
  34.  
  35. ?>
  36. <html>
  37. <head>
  38. <title>
  39. Login Form
  40. </title>
  41.  
  42. <style>
  43. body {
  44. background-color: #c0c0c0;
  45. padding-top: 50px;
  46. padding-bottom: 50px;
  47. position: relative;
  48. }
  49.  
  50. .container{
  51.  
  52. border-radius: 5px;
  53. padding: 20px;
  54. text-align: center;
  55. }
  56. input[type=text] {
  57. box-shadow: 2px 2px #838789;
  58. opacity: 0.8;
  59. border-radius: 5px;
  60. width: 250px;
  61. height: 40px;
  62. border: 3px darkgrey;
  63. margin:auto;
  64. margin-bottom: 5px;
  65. display: inline-block;
  66. padding: 12px 20px;
  67.  
  68. }
  69.  
  70. input[type=password] {
  71. box-shadow: 2px 2px #838789;
  72. opacity: 0.8;
  73. border-radius: 5px;
  74. width: 250px;
  75. height: 40px;
  76. border: 3px darkgrey;
  77. margin:auto;
  78. margin-bottom: 20px;
  79. display: inline;
  80. padding: 12px 20px;
  81.  
  82.  
  83. }
  84.  
  85. input[type=submit]:hover{
  86.  
  87.  
  88.  
  89. }
  90.  
  91. p{
  92. font-style: italic;
  93. font-family: Verdana;
  94. text-align: center;
  95. }
  96.  
  97. form{
  98. margin: 0 auto;
  99. width:250px;
  100.  
  101. }
  102. </style>
  103.  
  104.  
  105. </head>
  106.  
  107. <body>
  108.  
  109.  
  110. <div class="container">
  111. <form action="<?php echo htmlspecialchars($_SERVER['PHP_SELF']); ?>"
  112. method="post"; accept-charset="UTF-8">
  113. <p> Username:</p>
  114. <input type="text" align="center" name="name" maxlength="50" autofocus> <br/>
  115. <p>Password: </p>
  116. <input type="password" name="password" maxlength="50"><br/>
  117. <input type="submit" name="login" value="Submit" formtarget="_blank">
  118. </form>
  119.  
  120. </div>
  121. </body>
  122. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement