Advertisement
Guest User

Untitled

a guest
Apr 26th, 2015
197
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 2.13 KB | None | 0 0
  1. <?php
  2. include("include/BasicLib.php");
  3. ?>
  4. <h1>Log In</h1>
  5.  
  6. <script type="text/javascript">
  7.     $(document).ready(function() {
  8.       $("#submit").click(function(){
  9.         var username = $("#username").val();
  10.         var password = $("#password").val();
  11.         $.post(
  12.             "login.php",
  13.             {
  14.                 username: username,
  15.                 password: password
  16.             },
  17.             function(msg)
  18.             {
  19.                 $("#section").html(msg);
  20.             });
  21.     });
  22.   });
  23.  
  24.     $('#password').change(function(e) {
  25.         $('input[type=button]').click();
  26.     });
  27. </script>
  28.  
  29. <?php
  30. if($logged)
  31. {        
  32.     echo "Sei già loggato... Verrai reinderizzato alla home!";
  33.     ?>
  34.     <script type="text/javascript">
  35.         setTimeout(function(){ homepage(); }, 1500);
  36.     </script>
  37.     <?php
  38. }
  39. else if(@checkParameter($_POST['username']) && @checkParameter($_POST['password']))
  40. {
  41.     $username = $conn->escape_string($_POST['username']);
  42.     $password = $conn->escape_string($_POST['password']);
  43.  
  44.     $SQL = "SELECT ID FROM Utenti WHERE Username ='".$username."' AND Password ='".$password."'";
  45.  
  46.     $result = $conn->query($SQL);
  47.  
  48.     $row = $result->fetch_assoc();
  49.  
  50.     if($row)
  51.     {
  52.         setSession($row['ID'], $username, $password);
  53.         echo "Login effettuato... Verrai reinderizzato alla home!";
  54.         ?>
  55.         <script type="text/javascript">
  56.             setTimeout(function(){ window.location.href = "index.php"; }, 1500);
  57.         </script>
  58.         <?php
  59.     }
  60.     else
  61.     {
  62.         echo "Username o Password errati!";
  63.     }
  64. }
  65. else
  66. {
  67.     ?>
  68.     <form name="Login">
  69.  
  70.         <h3 class="center">Username</h3>
  71.         <input type="text" id="username" name="username" pattern=".{3,10}" placeholder="Minimo 3, Massimo 10">
  72.  
  73.         <br>
  74.  
  75.         <h3 class="center">Password</h3>
  76.         <input type="password" id="password" name="password" pattern=".{6,16}" placeholder="Minimo 6, Massimo 16">
  77.  
  78.         <br>            
  79.         <br>
  80.  
  81.         <input class="buttonStyle" type="button" id="submit" value="Login">
  82.  
  83.     </form>
  84.     <?php
  85. }
  86. $conn->close();
  87. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement