Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- $servername = "localhost";
- $username = "root";
- $password = "";
- $dbname = "loginform";
- $conn = new mysqli($servername, $username, $password, $dbname);
- if ($conn->connect_error) {
- die("Connection failed: " . $conn->connect_error);
- }
- if(isset($_POST['login'])){
- $username = $_POST['name'];
- $pass = $_POST['password'];
- $sql = "SELECT * FROM users WHERE name ='$username' AND password ='$pass' ";
- $result = $conn->query($sql);
- if ($result->num_rows > 0) {
- session_start();
- echo 'esti logat';
- }
- }
- ?>
- <html>
- <head>
- <title>
- Login Form
- </title>
- <style>
- body {
- background-color: #c0c0c0;
- padding-top: 50px;
- padding-bottom: 50px;
- position: relative;
- }
- .container{
- border-radius: 5px;
- padding: 20px;
- text-align: center;
- }
- input[type=text] {
- box-shadow: 2px 2px #838789;
- opacity: 0.8;
- border-radius: 5px;
- width: 250px;
- height: 40px;
- border: 3px darkgrey;
- margin:auto;
- margin-bottom: 5px;
- display: inline-block;
- padding: 12px 20px;
- }
- input[type=password] {
- box-shadow: 2px 2px #838789;
- opacity: 0.8;
- border-radius: 5px;
- width: 250px;
- height: 40px;
- border: 3px darkgrey;
- margin:auto;
- margin-bottom: 20px;
- display: inline;
- padding: 12px 20px;
- }
- input[type=submit]:hover{
- }
- p{
- font-style: italic;
- font-family: Verdana;
- text-align: center;
- }
- form{
- margin: 0 auto;
- width:250px;
- }
- </style>
- </head>
- <body>
- <div class="container">
- <form action="<?php echo htmlspecialchars($_SERVER['PHP_SELF']); ?>"
- method="post"; accept-charset="UTF-8">
- <p> Username:</p>
- <input type="text" align="center" name="name" maxlength="50" autofocus> <br/>
- <p>Password: </p>
- <input type="password" name="password" maxlength="50"><br/>
- <input type="submit" name="login" value="Submit" formtarget="_blank">
- </form>
- </div>
- </body>
- </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement