Advertisement
Guest User

Untitled

a guest
May 1st, 2017
57
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.58 KB | None | 0 0
  1. <html>
  2. <head>
  3. <link rel="stylesheet" href="style.css">
  4. <title>De Canio & Varotto</title>
  5. </head>
  6. <body>
  7.  
  8. <form id="form" action="#" method="post">
  9. <div id="login" align="center">
  10. <div id="login-top">
  11. <h3>Login Panel</h3>
  12. </div>
  13. <hr>
  14. <table>
  15. <tr><td align="center"><p>Username </p></td>
  16. <td ><input type="text" name="user"></td></tr>
  17. <tr><td align="center"><p>Password </p></td>
  18. <td><input type="password" name="pass" ></td></tr>
  19. <tr><td><input type="submit" name="submit" value="OK" id="btn" ></td></tr>
  20. <table>
  21. </div>
  22. </form>
  23.  
  24. <?php
  25. session_start();
  26. function checklogin($x,$y,$conn){
  27.  
  28. $q="select user,pass from Membri";
  29. $res=mysqli_query($conn,$q);
  30.  
  31. while($row=mysqli_fetch_array($res)){
  32.  
  33. $u=$row['user'];
  34. $p=$row['pass'];
  35.  
  36. if($u==$x && $p==$y){
  37. return true;
  38. break;
  39. }}}
  40.  
  41. if(isset($_POST['submit'])){
  42. $user=$_POST['user'];
  43. $pass=$_POST['pass'];
  44.  
  45.  
  46. if($user!=null && $pass!=null){
  47.  
  48. $conn=mysqli_connect("localhost","root","");
  49. $db=mysqli_select_db($conn,"telefonia");
  50. if(checklogin($user,$pass,$conn)){
  51.  
  52. echo "<p id='check' style='color:green;'>login corretto</p>";
  53.  
  54. $_SESSION['user']=$_POST['user'];
  55. $_SESSION['pass']=$_POST['pass'];
  56.  
  57. header("Location:main-page.php");
  58.  
  59. }else{
  60.  
  61. echo "<p id='check' style='color:red;'>login errato</p>";
  62. }
  63. }else{
  64.  
  65. echo "<p id='check' style='color:red;'>inserisci i campi mancanti</p>";
  66. }
  67.  
  68. }
  69.  
  70. ?>
  71. </body>
  72. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement