Advertisement
Shockrate

login

Apr 18th, 2019
245
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.33 KB | None | 0 0
  1. login.php
  2. ----------------------------------------------------------------------------
  3. <?php
  4. // Always start this first
  5. session_start();
  6.  
  7. if ( ! empty( $_POST ) ) {
  8. if ( isset( $_POST['username'] ) && isset( $_POST['password'] ) ) {
  9.  
  10. $user = $_POST['username'];
  11. $pass = $_POST['password'];
  12. $servername = "localhost";
  13. $username = "aristons";
  14. $password = "hyrasxgraz65!";
  15. $dbname = "aristons_programmazione";
  16. $link = new mysqli($servername, $username, $password, $dbname);
  17.  
  18.  
  19. $sqlricerca = "SELECT * FROM login WHERE username = '$user'";
  20. //echo $sqlricerca;
  21. $rispsw = mysqli_query($link,$sqlricerca);
  22. $numrows = mysqli_num_rows($rispsw);
  23. if ($numrows>0){
  24. while($psr = $rispsw->fetch_assoc()){
  25. $pswdb = $psr['pass'];
  26. $id = $psr['id'];
  27. }
  28. }else{
  29. echo "username non trovato";
  30. }
  31.  
  32.  
  33. $passmd5 = md5($pass);
  34.  
  35. // Verify user password and set $_SESSION
  36. if ($passmd5 == $pswdb ) {
  37. $_SESSION['user_id'] = $id;
  38. }
  39. }
  40. }
  41. ?>
  42.  
  43.  
  44. index.php // tutte le pagine
  45. -------------------------------------
  46. <?php
  47. include('login.php'); // Includes Login Script
  48.  
  49. if(isset($_SESSION['user_id'])){
  50. header("location: /home.php");
  51. }
  52. ?>
  53.  
  54. <?php
  55. include('login.php'); // Includes Login Script
  56.  
  57. if(isset($_SESSION['user_id'])){
  58. header("location: /home.php");
  59. }
  60. ?>
  61. <link rel="stylesheet" type="text/css" href="/cssagg.css">
  62.  
  63. <!DOCTYPE html>
  64. <html>
  65. <body>
  66. <div class="contenuto">
  67. <div class="logoariston"><img src="http://www.aristonsanremo.com/wp-content/uploads/2015/09/Logo-Ariston2.png" width="200"></div>
  68.  
  69. <center><br><br><br>
  70. <form action="" method="post">
  71. <label>USER :</label>
  72. <input id="name" name="username" placeholder="username" type="text"><br>
  73. <label>PASSWORD :</label>
  74. <input id="password" name="password" placeholder="**********" type="password"><br><br>
  75. <input name="submit" type="submit" value=" Login ">
  76. </form>
  77. </center>
  78. </div>
  79. </body>
  80. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement