Advertisement
Guest User

Untitled

a guest
Aug 23rd, 2016
106
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.58 KB | None | 0 0
  1. <?php
  2. //Start the Session
  3. session_start();
  4. require('config.php');
  5. //3. If the form is submitted or not.
  6. //3.1 If the form is submitted
  7. if (isset($_POST['username']) and isset($_POST['password'])){
  8. //3.1.1 Assigning posted values to variables.
  9. $username = $_POST['username'];
  10. $password = $_POST['password'];
  11. //3.1.2 Checking the values are existing in the database or not
  12. $query = "SELECT * FROM `users` WHERE username='$username' and password='$password'";
  13.  
  14. $result = mysqli_query($connection, $query) or die(mysqli_error($connection));
  15. $count = mysqli_num_rows($result);
  16. //3.1.2 If the posted values are equal to the database values, then session will be created for the user.
  17. if ($count == 1){
  18. $_SESSION['username'] = $username;
  19. }else{
  20. //3.1.3 If the login credentials doesn't match, he will be shown with an error message.
  21. $fmsg = "Invalid Login Credentials.";
  22. }
  23. }
  24. //3.1.4 if the user is logged in Greets the user with message
  25. if (isset($_SESSION['username'])){
  26. $username = $_SESSION['username'];
  27. header('Location: admincp.html'); // Redirecting To Home Page
  28. }
  29. //3.2 When the user visits the page first time, simple login form will be displayed.
  30. ?>
  31. <html>
  32. <head>
  33. <title> GijoeTeam LoginPanel</title>
  34. <link href="css/admincp.css" rel="stylesheet" type="text/css" media="screen">
  35. <script src="js/jquery.js" type="text/javascript"></script>
  36. <link rel="stylesheet" href="http://www.w3schools.com/lib/w3.css">
  37. <meta name="viewport" content="width=device-width, initial-scale=1.0">
  38.  
  39. <style>
  40. .button {
  41. background-color: #4CAF50; /* Green */
  42. border: none;
  43. color: white;
  44. padding: 16px 32px;
  45. text-align: center;
  46. text-decoration: none;
  47. display: inline-block;
  48. font-size: 16px;
  49. margin: 4px 2px;
  50. -webkit-transition-duration: 0.4s; /* Safari */
  51. transition-duration: 0.4s;
  52. cursor: pointer;
  53. }
  54.  
  55. .button1 {
  56. background-color: white;
  57. color: black;
  58. border: 2px solid #4CAF50;
  59. }
  60.  
  61. .button1:hover {
  62. background-color: #4CAF50;
  63. color: white;
  64. }
  65.  
  66. .button2 {
  67. background-color: white;
  68. color: black;
  69. border: 2px solid #008CBA;
  70. }
  71.  
  72. .button2:hover {
  73. background-color: #008CBA;
  74. color: white;
  75. }
  76.  
  77. .button3 {
  78. background-color: white;
  79. color: black;
  80. border: 2px solid #f44336;
  81. }
  82.  
  83. .button3:hover {
  84. background-color: #f44336;
  85. color: white;
  86. }
  87.  
  88. .button4 {
  89. background-color: white;
  90. color: black;
  91. border: 2px solid #e7e7e7;
  92. }
  93.  
  94. .button4:hover {background-color: #e7e7e7;}
  95.  
  96. .button5 {
  97. background-color: white;
  98. color: black;
  99. border: 2px solid #555555;
  100. }
  101.  
  102. .button5:hover {
  103. background-color: #555555;
  104. color: white;
  105. }
  106. </style>
  107. </head>
  108.  
  109.  
  110.  
  111.  
  112. <body class="w3-container">
  113.  
  114.  
  115.  
  116. <header class="w3-container w3-teal">
  117.  
  118. <h1>Gijoe LoginPanel</h1>
  119. </header>
  120.  
  121. <div id="loginp" class="cities">
  122. <p>
  123. <form action="login.php" method="post" enctype="multipart/form-data">
  124. <input type="text" id="username" name="username" placeholder="Username">
  125. <input type="password" id="password" name="password" placeholder="Password">
  126. <button type="submit" class="button button2">Login</button>
  127. </p>
  128. </form>
  129.  
  130.  
  131. </div>
  132.  
  133.  
  134.  
  135. </body>
  136. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement