Advertisement
Guest User

Untitled

a guest
Feb 12th, 2016
95
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.17 KB | None | 0 0
  1. if ($stmt->execute()):
  2. echo 'Well done! You have successfully registered with us!';
  3. else:
  4. echo 'There seems to be an issue getting you registered.';
  5.  
  6. <?php
  7.  
  8. ini_set('display_errors', 'On');
  9. ini_set('html_errors', 0);
  10. error_reporting(-1);
  11.  
  12. require 'connection.php';
  13.  
  14. $message = '';
  15.  
  16. if (!empty($_POST['username']) && !empty($_POST['password'])):
  17.  
  18. // $username = $_POST['username'];
  19. $password = $_POST['password'];
  20. $confirmpassword = $_POST['confirmpassword'];
  21.  
  22. //var_dump($password, $confirmpassword);
  23.  
  24. if($password == $confirmpassword):
  25.  
  26. $sql = "INSERT INTO users (FirstName, LastName, Role, Email, Username, Password) VALUES (:firstname, :lastname, :role, :email, :username, :password)";
  27. $stmt = $conn->prepare($sql);
  28. $hashPassword = password_hash($password, PASSWORD_DEFAULT);
  29.  
  30. $stmt->bindParam(':firstname', $_POST['firstname']);
  31. $stmt->bindParam(':lastname', $_POST['lastname']);
  32. $stmt->bindParam(':role', $_POST['role']);
  33. $stmt->bindParam(':email', $_POST['email']);
  34. $stmt->bindParam(':username', $_POST['username']);
  35. $stmt->bindParam(':password', $hashPassword);
  36.  
  37. if ($stmt->execute()):
  38. echo 'Well done! You have successfully registered with us!';
  39. //$message = 'Well done! You have successfully registered with us!';
  40. //header('Location:loginPage.php');
  41. else:
  42. echo 'There seems to be an issue getting you registered.';
  43. //$message = 'There seems to be an issue getting you registered.';
  44. //else:
  45. //echo 'Your passwords do not match!';
  46. //$message = 'Your passwords do not match, please enter them correctly.';
  47.  
  48. endif;
  49.  
  50. endif;
  51.  
  52. endif;
  53.  
  54. --><form class="col-1-3" action="register.php" method="post">
  55.  
  56. <fieldset class="register-group">
  57.  
  58. <label>
  59. <br>First Name*
  60. <input type="text" name="firstname" placeholder="FirstName" value="<?php echo $firstname; ?>">
  61. </label>
  62.  
  63. <label>
  64. Last Name*
  65. <input type="text" name="lastname" placeholder="LastName" value="<?php echo $lastname; ?>">
  66. </label>
  67.  
  68. <label>
  69. Role*
  70. <select name="role">
  71. <option value="Student" selected>Student</option>
  72. <option value="Tutor" selected>Tutor</option>
  73. <option value="Admin" selected>Admin</option>
  74. </select>
  75. </label>
  76.  
  77. <label>
  78. Email Address*
  79. <input type="email" name="email" placeholder="Email" value="<?php echo $email; ?>">
  80. </label>
  81.  
  82. <label>
  83. Choose a Username*
  84. <input type="text" name="username" placeholder="Username" value="<?php echo $username; ?>">
  85. </label>
  86.  
  87. <label>
  88. Choose a Password*
  89. <input type="password" name="password" placeholder="Password">
  90. </label>
  91.  
  92. <label>
  93. Repeat Password*
  94. <input type="password" name="confirmpassword" placeholder="Confirm Password">
  95. </label>
  96.  
  97. <input class="btn btn-default" type="submit" name="register" value="Register">
  98.  
  99. </form>
  100.  
  101. if (!empty($_POST['username']) && !empty($_POST['password'])):
  102. //...
  103. if($password == $confirmpassword):
  104. //...
  105. if ($stmt->execute()):
  106. echo 'Well done! You have successfully registered with us!';
  107. //...
  108. else:
  109. echo 'There seems to be an issue getting you registered.';
  110. //...
  111. endif;
  112. else:
  113. echo 'Your passwords do not match!';
  114. //...
  115. endif;
  116. endif;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement