Advertisement
Guest User

Ex

a guest
Aug 24th, 2016
122
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 2.10 KB | None | 0 0
  1. <?php
  2.    include("config.php");
  3.    @session_start();
  4.    
  5.    if($_SERVER["REQUEST_METHOD"] == "POST") {
  6.       // username and password sent from form
  7.      
  8.       $myusername = mysqli_real_escape_string($db,$_POST['username']);
  9.       $mypassword = mysqli_real_escape_string($db,$_POST['password']);
  10.      
  11.       $sql = "SELECT id FROM users WHERE nick = '$myusername' and pass = '$mypassword'";
  12.       $result = mysqli_query($db,$sql);
  13.       $row = mysqli_fetch_array($result,MYSQLI_ASSOC);
  14.      
  15.       $count = mysqli_num_rows($result);
  16.      
  17.       // If result matched $myusername and $mypassword, table row must be 1 row
  18.        
  19.       if($count == 1) {
  20.          $_SESSION['login_user'] = $myusername;
  21.          
  22.          header("location: welcome.php");
  23.       }else {
  24.          $error = "Twoja hasło lub nazwa użytkownika są niepoprawne";
  25.       }
  26.    }
  27. ?>
  28. <html>
  29.    
  30.    <head>
  31.      
  32.       <style type = "text/css">
  33.          body {
  34.             font-family:Arial, Helvetica, sans-serif;
  35.             font-size:14px;
  36.          }
  37.          
  38.          label {
  39.             font-weight:bold;
  40.             width:100px;
  41.             font-size:14px;
  42.          }
  43.          
  44.          .box {
  45.             border:#666666 solid 1px;
  46.          }
  47.       </style>
  48.      
  49.    </head>
  50.    
  51.    <body bgcolor = "#FFFFFF">
  52.    
  53.    
  54.          <div style = "width:300px; border-right: solid 1px #e2dec8; margin-top: -145px; margin-left: 717px;">
  55.             <div style = "background-color:#3F73BA; color:#fff; padding:8px;"><b>Logowanie</b></div>
  56.             <table>
  57.             <div style = "margin:15px">
  58.                <td>
  59.                <form action = "logowanie.php" method = "post">
  60.                
  61.                   <label>Nazwa użytkownika:</label><input type = "text" name = "username" class = "box"/><br>
  62.                   <label>Hasło:</label><br><input type = "password" name = "password" class = "box" /><br/><br /></td>
  63.                   <td><input type = "submit" value = " Zaloguj "/></td>
  64.                </form>
  65.                </table>
  66.              
  67.                    
  68.             </div>
  69.                
  70.          </div>
  71.            
  72.      
  73.  
  74.    </body>
  75. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement