Guest User

Untitled

a guest
Oct 21st, 2018
375
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.49 KB | None | 0 0
  1. <?php
  2. session_start();
  3. if(isset($_SESSION['login'])){
  4. if($_SESSION['login'] == '1'){
  5. header("location:memberpage.php");
  6. }
  7. }
  8. ?>
  9. <html>
  10. <LINK REL=StyleSheet HREF="stylesheet.css" TITLE="Contemporary">
  11. <body>
  12. <div id="meny"><a href="registration.php">Registrera dig</a></div>
  13. <div id="huvudbox">
  14. <?php
  15. /*Includes at the top */
  16. include 'config/config.php';
  17. include 'config/functions.php';
  18. if(isset($_GET["auth"])){
  19. if($_GET["auth"] != "error"){
  20. ?>
  21. <form action="checklogin.php" method="post">
  22. Användare: <input type="text" name="Username" />
  23. Lösenord: <input type="password" name="Password" />
  24. <input type="submit" text="login" />
  25. </form>
  26. <?php
  27. }
  28. else if($_GET["auth"] = "error"){
  29. echo 'Wrong password & username';
  30.  
  31.  
  32. ?>
  33. <form action="checklogin.php" method="post">
  34. Username: <input type="text" name="Username" />
  35. Password: <input type="password" name="Password" />
  36. <input type="submit" text="login" />
  37. </form>
  38. <?php
  39. }
  40. }
  41. else{
  42. ?>
  43. <form action="checklogin.php" method="post">
  44. Username: <input type="text" name="Username" /><br/>
  45. Password: <input type="password" name="Password" /><br/>
  46. <input type="submit" text="login" />
  47. </form>
  48.  
  49. <?php
  50. }
  51. mysqlClose();
  52. ?>
  53. </div>
  54. </body>
  55. </html>
  56.  
  57. // check login
  58.  
  59. <?php
  60. session_start();
  61. /*Includes at the top */
  62. include 'config/config.php';
  63. include 'config/functions.php';
  64. /*
  65. Session
  66. */
  67. /*Variablar*/
  68. $user = htmlentities($_POST["Username"]);
  69. $pass = htmlentities($_POST["Password"]);
  70. $passhash = hash('whirlpool',$pass);
  71. $result = mysql_query("SELECT * FROM users WHERE Username='$user' AND Password='$passhash' ");
  72. $count=mysql_num_rows($result);
  73.  
  74. if($count==1){
  75. $_SESSION['login'] = 1;
  76. while ($row = mysql_fetch_array($result, MYSQL_ASSOC)) {
  77. $userid = $row['Id'];
  78. }
  79. $_SESSION['id'] = $userid;
  80. header("location:index.php");
  81. }
  82. else {
  83. header("location:login.php?auth=error");
  84. $_SESSION['login'] = 0;
  85. }
  86.  
  87. ?>
  88.  
  89.  
  90. //Logout
  91. <?php
  92. /*Includes at the top */
  93. session_start();
  94. $_SESSION['login'] = '0';
  95. include 'config/config.php';
  96. include 'config/functions.php';
  97. ?>
  98. <html>
  99. <LINK REL=StyleSheet HREF="stylesheet.css" TITLE="Contemporary">
  100. <body>
  101. <div id="meny"><a href="memberpage.php">Hem</a> <a href="products.php">Våran Produkter</a> <a href="logout.php">Logga ut</a></div>
  102. <div id="huvudbox">
  103. Du har nu loggats ut, klicka <a href="login.php?auth=">här</a> för att fullborda önskan<br>
  104. <br>
  105. <br>
  106. <br>
  107. <?php
  108. ?>
  109. </div>
  110. </body>
  111. </html>
Add Comment
Please, Sign In to add comment