Advertisement
Guest User

Untitled

a guest
Aug 18th, 2016
80
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 3.33 KB | None | 0 0
  1. <?php
  2.         include("config.php");
  3.       $error_msg = "";
  4.     //checks the session to see if the user is logged in
  5.     if (!isset($_SESSION['username'])) {
  6.         if (!isset($_POST['submit'])) {
  7.  
  8.             //grabs data from POST
  9.             $username = $_POST['username'];
  10.             $password = $_POST['password'];
  11.             //lookup username and password in the database
  12.             if (!empty($username) && !empty($password)) {
  13.                 if ($result = mysqli_query($dbc, "SELECT COUNT(*) FROM users WHERE username='" . $username . "'
  14.                 AND password='".$password."'")) {
  15.                     $row = mysqli_fetch_assoc($result);
  16.                       if ($row['COUNT(*)'] == 0) {
  17.                     $_SESSION['username'] = $row['username'];
  18.                     //redirect after successful login
  19.                     header("Location: admincp.html");
  20.                 } else {
  21.                     //the username and password are incorrect so set error message
  22.                     $error_msg = 'Sorry, you must enter a valid username and password to log in. <a href="Signup.php">Please sign up!</a>';
  23.                 }
  24.                 }
  25.             }
  26.         }
  27.     }
  28. ?>
  29.     <html>
  30.     <head>
  31.      <title> GijoeTeam LoginPanel</title>
  32.      <link href="css/admincp.css" rel="stylesheet" type="text/css" media="screen">
  33.      <script src="js/jquery.js" type="text/javascript"></script>
  34.      <link rel="stylesheet" href="http://www.w3schools.com/lib/w3.css">
  35.      <meta name="viewport" content="width=device-width, initial-scale=1.0">
  36.          
  37.             <style>
  38.                   .button {
  39.                 background-color: #4CAF50; /* Green */
  40.                 border: none;
  41.                 color: white;
  42.                 padding: 16px 32px;
  43.                 text-align: center;
  44.                 text-decoration: none;
  45.                 display: inline-block;
  46.                 font-size: 16px;
  47.                 margin: 4px 2px;
  48.                 -webkit-transition-duration: 0.4s; /* Safari */
  49.                 transition-duration: 0.4s;
  50.                 cursor: pointer;
  51.             }
  52.            
  53.             .button1 {
  54.                 background-color: white;
  55.                 color: black;
  56.                 border: 2px solid #4CAF50;
  57.             }
  58.            
  59.             .button1:hover {
  60.                 background-color: #4CAF50;
  61.                 color: white;
  62.             }
  63.            
  64.             .button2 {
  65.                 background-color: white;
  66.                 color: black;
  67.                 border: 2px solid #008CBA;
  68.             }
  69.            
  70.             .button2:hover {
  71.                 background-color: #008CBA;
  72.                 color: white;
  73.             }
  74.            
  75.             .button3 {
  76.                 background-color: white;
  77.                 color: black;
  78.                 border: 2px solid #f44336;
  79.             }
  80.            
  81.             .button3:hover {
  82.                 background-color: #f44336;
  83.                 color: white;
  84.             }
  85.            
  86.             .button4 {
  87.                 background-color: white;
  88.                 color: black;
  89.                 border: 2px solid #e7e7e7;
  90.             }
  91.            
  92.             .button4:hover {background-color: #e7e7e7;}
  93.            
  94.             .button5 {
  95.                 background-color: white;
  96.                 color: black;
  97.                 border: 2px solid #555555;
  98.             }
  99.            
  100.             .button5:hover {
  101.                 background-color: #555555;
  102.                 color: white;
  103.             }
  104.             </style>
  105.     </head>
  106.        
  107.        
  108.  
  109.        
  110.     <body class="w3-container">
  111.          
  112.          
  113.          
  114.         <header class="w3-container w3-teal">
  115.  
  116.         <h1>Gijoe LoginPanel</h1>
  117.         </header>
  118.            
  119.            <div id="loginp" class="cities">
  120.             <p>
  121.             <form action="login.php" method="post" enctype="multipart/form-data">
  122.            <input type="text" id="username" name="username" placeholder="Username">
  123.            <input type="password" id="password" name="password" placeholder="Password">
  124.             <button type="submit" class="button button2">Login</button>
  125.             </p>
  126.             </form>
  127.            
  128.  
  129.             </div>
  130.            
  131.          
  132.          
  133.     </body>
  134.     </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement