Advertisement
Guest User

Untitled

a guest
Oct 23rd, 2018
107
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.60 KB | None | 0 0
  1. <?php
  2. include("includes/connect.php");
  3. $error = "";
  4.  
  5. if($_SERVER["REQUEST_METHOD"] == "POST") {
  6. $User = mysqli_real_escape_string($db,$_POST['User']);
  7. $Email = mysqli_real_escape_string($db,$_POST['Email']);
  8. $Pass = mysqli_real_escape_string($db,$_POST['Pass']);
  9. $RPass = mysqli_real_escape_string($db,$_POST['RPass']);
  10. if ($Pass == $RPass) {
  11. $sqlquery = "SELECT ID FROM users WHERE Email='$Email'";
  12. $sqlresult = $db->query($sqlquery);
  13. $sqlquery1 = "SELECT ID FROM users WHERE User='$User'";
  14. $sqlresult1 = $db->query($sqlquery1);
  15. if ($sqlresult->num_rows == 0) {
  16. if ($sqlresult1->num_rows == 0) {
  17. $options = [
  18. 'cost' => 12,
  19. ];
  20. $hash = password_hash($Pass, PASSWORD_BCRYPT, $options);
  21. $sqlinsert = "INSERT INTO users (User, Pass, Email) VALUES ('$User', '$hash', '$Email')";
  22. $db->query($sqlinsert);
  23. header("location: login.php");
  24. }else {
  25. $error = "Username is already in use";
  26. }
  27. } else {
  28. $error = "Email is already in use";
  29. }
  30.  
  31. } else {
  32. $error = "Passwords didnt match";
  33. }
  34. }
  35. ?>
  36. <html>
  37. <head>
  38. <title>ASG | Signup</title>
  39. <style type = "text/css">
  40. body {
  41. font-family:Arial, Helvetica, sans-serif;
  42. font-size:14px;
  43. }
  44. label {
  45. font-weight:bold;
  46. width:100px;
  47. font-size:14px;
  48. }
  49. .box {
  50. border:#666666 solid 1px;
  51. margin: 1px;
  52. }
  53. .submit {
  54. border: lightgray solid 1px;
  55. background-color: white;
  56. color: black;
  57. text-align: center;
  58. text-decoration: none;
  59. display:inline-block;
  60. font-size: 16px;
  61. padding: 4px 12px 4px 12px;
  62. margin-top: 4px;
  63. }
  64. .submit:hover{
  65. background-color: lightgray;
  66. border: black solid 1px;
  67. }
  68. </style>
  69. </head>
  70. <body>
  71. <form action="" method="post">
  72. <label>Username: </label><input type="text" name="User" class="box"><br>
  73. <label>E-mail: </label><input type="email" name="Email" class="box"><br>
  74. <label>Password: </label><input type="password" name="Pass" class="box"><br>
  75. <label>Repeat Password: </label><input type="password" name="RPass" class="box"><br>
  76. <input type="submit" class="submit"><p style = "font-size:15px; color:#cc0000; margin-top:10px; font-weight: bold;"><?php echo $error; ?></p>
  77. </form>
  78. </body>
  79. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement