Advertisement
Guest User

Untitled

a guest
Feb 22nd, 2016
100
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.71 KB | None | 0 0
  1. <?php
  2.  
  3. ?>
  4. <!DOCTYPE html>
  5. <html>
  6. <center>
  7. <head>
  8. <meta charset="utf-8">
  9. <title>Login</title>
  10. <link rel="stylesheet" href="style.css" />
  11. </head>
  12. <body>
  13. <?php
  14. require('db.php');
  15. session_start();
  16. // If form submitted, insert values into the database.
  17. if (isset($_POST['username'])) {
  18.     $username = $_POST['username'];
  19.     $password = $_POST['password'];
  20.     $username = stripslashes($username);
  21.     $username = mysql_real_escape_string($username);
  22.     $password = stripslashes($password);
  23.     $password = mysql_real_escape_string($password);
  24.     //Checking is user existing in the database or not
  25.     $query    = "SELECT * FROM `users` WHERE username='$username' and password='" . md5($password) . "'";
  26.     $result = mysql_query($query) or die(mysql_error());
  27.     $rows = mysql_num_rows($result);
  28.     if ($rows == 1) {
  29.         $_SESSION['username'] = $username;
  30.         header("Location: index.php"); // Redirect user to index.php
  31.     } else {
  32.         echo "<div class='form'><h3>Username/password is incorrect.</h3><br/>Click here to <a href='login.php'>Login</a></div>";
  33.     }
  34. } else {
  35. ?>
  36. <div class="form">
  37. <body style="margin-top: 5cm;">
  38. <body bgcolor="#E6E6FA">
  39. <img src="lock_image.png" alt="Lock Image" style="width:90px;height:90px;">
  40. <font face="verdana" color="grey"><h1>LOG IN</h1></font>
  41. <form action="" method="post" name="login">
  42. <input type="text" name="username" placeholder="Username" required />
  43. <input type="password" name="password" placeholder="Password" required />
  44. <input name="submit" type="submit" value="Login" />
  45. </form>
  46. <p style="font-family:verdana;">Not registered yet? <br ><a href='registration.php'>Register Here</a></p>
  47. </div>
  48. <?php
  49. }
  50. ?>
  51. </center>
  52. </body>
  53. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement