Advertisement
Guest User

Untitled

a guest
Oct 9th, 2016
96
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.92 KB | None | 0 0
  1. <?php
  2. session_start();
  3. if(isset($_SESSION['user'])!="")
  4. {
  5. header("Location: http://www.skolahysing.com/nemendur/tindur/gso300/verkefni5/normal/index.php");
  6. }
  7. include_once $_SERVER['DOCUMENT_ROOT']. '/nemendur/tindur/include/db.inc.php';
  8.  
  9. if (isset($_POST['btn-signup']))
  10. {
  11. $securepass = password_hash($_POST['pass'],PASSWORD_DEFAULT);
  12.  
  13. try
  14. {
  15. $sql ='INSERT INTO users SET
  16. username = :uname,
  17. email =:email,
  18. password = :upass';
  19. $s = $pdo->prepare($sql);
  20. $s->bindValue(':uname', $_POST['uname']);
  21. $s->bindValue(':email', $_POST['email']);
  22. $s->bindValue(':upass', $securepass);
  23. $s->execute();
  24.  
  25. }
  26. catch (PDOException $e)
  27. {
  28. $error = 'Error adding registering user.' . $e->getMessage();
  29. include $_SERVER['DOCUMENT_ROOT'] . '/nemendur/tindur/gso300/verkefni5/login/error.html.php';
  30. exit();
  31. }
  32. header('Location: . ');
  33. exit();
  34. }
  35.  
  36. include 'register.html.php';
  37.  
  38.  
  39.  
  40.  
  41.  
  42.  
  43.  
  44.  
  45.  
  46.  
  47.  
  48.  
  49.  
  50.  
  51.  
  52.  
  53.  
  54.  
  55.  
  56.  
  57.  
  58.  
  59.  
  60.  
  61. ?>
  62.  
  63.  
  64.  
  65.  
  66.  
  67.  
  68. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
  69. <html xmlns="http://www.w3.org/1999/xhtml">
  70. <head>
  71. <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
  72. <title>Login & Registration System</title>
  73. <link rel="stylesheet" href="style.css" type="text/css" />
  74.  
  75. </head>
  76. <body>
  77. <center>
  78. <div id="login-form">
  79. <form method="post">
  80. <table align="center" width="30%" border="0">
  81. <tr>
  82. <td><input type="text" name="uname" placeholder="User Name" required /></td>
  83. </tr>
  84. <tr>
  85. <td><input type="email" name="email" placeholder="Your Email" required /></td>
  86. </tr>
  87. <tr>
  88. <td><input type="password" name="pass" placeholder="Your Password" required /></td>
  89. </tr>
  90. <tr>
  91. <td><button type="submit" name="btn-signup">Sign Me Up</button></td>
  92. </tr>
  93. <tr>
  94. <td><a href="../login/index.php">Sign In Here</a></td>
  95. </tr>
  96. </table>
  97. </form>
  98. </div>
  99. </center>
  100. </body>
  101. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement