Advertisement
Guest User

Untitled

a guest
Sep 19th, 2017
61
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 2.56 KB | None | 0 0
  1. <?php
  2. //include('login.php'); // Includes Login Script
  3. session_start(); // Starting Session
  4. $error=''; // Variable To Store Error Message
  5. if (isset($_POST['submit'])) {
  6. if (empty($_POST['username']) || empty($_POST['password'])) {
  7. $error = "Username or Password is invalid";
  8. }
  9. else
  10. {
  11. // Define $username and $password
  12. $username=$_POST['username'];
  13. $password=$_POST['password'];
  14. // Establishing Connection with Server by passing server_name, user_id and password as a parameter
  15. $connection = mysql_connect("localhost", "Database", "Password");
  16. // To protect MySQL injection for Security purpose
  17. $username = stripslashes($username);
  18. $password = stripslashes($password);
  19. $username = mysql_real_escape_string($username);
  20. $password = mysql_real_escape_string($password);
  21. // Selecting Database
  22. $db = mysql_select_db("julianme_Quick", $connection);
  23. // SQL query to fetch information of registerd users and finds user match.
  24. $query = mysql_query("select * from QuickFood_Werknemers where password='$password' AND username='$username'", $connection);
  25. $rows = mysql_num_rows($query);
  26. if ($rows == 1) {
  27. $_SESSION['login_user']=$username; // Initializing Session
  28. header("location: main.php"); // Redirecting To Other Page
  29. } else {
  30. $error = "Username or Password is invalid";
  31. }
  32. mysql_close($connection); // Closing Connection
  33. }
  34. }
  35.  
  36. if(isset($_SESSION['login_user'])){
  37. header("location: main.php");
  38. }
  39. ?>
  40. <!DOCTYPE html>
  41. <html >
  42. <head>
  43.   <meta charset="UTF-8">
  44.   <title>Quick Company</title>
  45.   <link href="https://fonts.googleapis.com/icon?family=Material+Icons"
  46.       rel="stylesheet">
  47. <link href='https://fonts.googleapis.com/css?family=Roboto:400,500' rel='stylesheet' type='text/css'>
  48.   <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/meyer-reset/2.0/reset.min.css">
  49.  
  50.  
  51.       <link rel="stylesheet" href="css/style.css">
  52.  
  53.  
  54. </head>
  55.  
  56. <body>
  57.   <div class="login-container">
  58.   <section class="login" id="login">
  59.     <header>
  60.       <h2>Quick Company</h2>
  61.       <h4>Login</h4>
  62.     </header>
  63.     <form class="login-form" action="" method="post">
  64.       <input type="text" class="login-input" name="username" id="name" placeholder="User"/>
  65.       <input type="password" class="login-input" name="password" id="password" placeholder="Password"/>
  66.       <div class="submit-container">
  67.         <button name="submit" type="submit" class="login-button">SIGN IN</button>
  68.       </div>
  69.     </form>
  70.   </section>
  71.   <p>2017 - <a href="https://www.twitter.com/x16julian16x">Julian Meurer</a></p>
  72. </div>
  73.     <script  src="js/index.js"></script>
  74. </body>
  75. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement