Advertisement
Guest User

Untitled

a guest
Jun 9th, 2016
66
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.78 KB | None | 0 0
  1. <html>
  2. <head>
  3.  
  4. </head>
  5.  
  6. <body>
  7. <?phps
  8.  
  9. if($_SERVER["REQUEST_METHOD"] == "post"){
  10. $login = $_POST["username"];
  11. $passowrd = $_POST["password"];
  12.  
  13. $passwordHash =hash("sha256", $password);
  14.  
  15. $con = new PDO("mysql:host=localhost;dbname=chat;","root", "");
  16. $con->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
  17.  
  18. $statement = $con->prepare("SELECT * FROM chat.login WHERE username = ? AND passwordHash = ?");
  19.  
  20. $statement->bindvalue(1, $login);
  21. $statement->bindvalue(2, $passwordHash);
  22.  
  23. $statement->execute();
  24.  
  25. $user = $statement->fetchObject();
  26.  
  27. var_dump($user);
  28. if($user == false)
  29. {
  30. echo "fout";
  31. }
  32. else
  33. {
  34. //header("location: https//www.google.com");
  35.  
  36. session_start();
  37. $_SESSION["user_name"] = $user->username;
  38. $_SESSION["user_id"] = $user->idlogin;
  39.  
  40. Header("location:securepage.php");
  41. }
  42. }
  43. ?>
  44.  
  45. <form method="post">
  46. Username:<br>
  47. <input type="text" name="firstname"><br>
  48. password:<br>
  49. <input type="password" name="lastname">
  50. <br><br>
  51.  
  52. <input type="submit" value="Login">
  53. </form>
  54. </body>
  55. </html>
  56.  
  57. <?php //checklogin
  58.  
  59. session_start();
  60.  
  61. $user = "";
  62.  
  63. if(isset($_SESSION["user_id"])){
  64.  
  65. $user = $_SESSION["user_name"];
  66. }
  67. else
  68. {
  69. header("location:oefenindex.php");
  70. }
  71.  
  72. ?>
  73.  
  74. <?php //passwordhash
  75.  
  76. echo hash("sha256","test");
  77.  
  78. ?>
  79.  
  80. ?php
  81.  
  82. session_start();
  83. if(isset($_session["username"])){
  84. echo("welkom".$session["username"])
  85. }
  86. else
  87. {
  88. header("location:oefenindex.php");
  89. }
  90. ?>
  91.  
  92.  
  93. <html> //veiligepagina
  94.  
  95. <?php
  96. include_once "./checklogin.php"
  97. ?>
  98.  
  99. <body>
  100.  
  101. welkom <?php echo $user; ?>
  102.  
  103.  
  104. <h2>KIFESH GEHIEMEN JIJ STREST OM DIE DONNIE</h2>
  105.  
  106. </body>
  107.  
  108. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement