Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <!DOCTYPE html>
- <html>
- <head>
- <meta charset="utf-8">
- <title>Login</title>
- <link rel="stylesheet" href="css/style.css"/>
- </head>
- <body>
- <?php
- require('db.php');
- session_start();
- if (isset($_POST['username'])){
- $username = $_REQUEST['username'];
- $password = $_REQUEST['password'];
- $sql = "SELECT * FROM `users` WHERE username='$username' and
- password='".md5($password)."'";
- $result = $conn->query($sql) or die(mysqli_error());
- if($result->num_rows > 0){
- $_SESSION['username'] = $username;
- header("Location: index.php"); //Redirect user to index.php
- }else{
- echo "<div class='form'><h3>Username/password is
- incorrect.</h3><br>Click here to <a
- href='login.php'>Login</a></div>";
- }
- }else{
- ?>
- <div class="form">
- <h1>Log In</h1>
- <form action="" method="post" name="login">
- <input type="text" name="username" placeholder="Username"
- required />
- <input type="password" name="password" placeholder="Password"
- required />
- <input name="submitted" type="submit" value="Login" />
- </form>
- <p>Not registered yet? <a href='registration.php'>Register
- Here</a></p>
- </div>
- <?php } ?>
- </body>
- </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement