Advertisement
Guest User

Untitled

a guest
Nov 4th, 2016
101
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 6.05 KB | None | 0 0
  1. <?php
  2. if(isset($_POST['submit'])){
  3.  
  4. include 'connection.php';
  5. $firstname = $_POST['firstname'];
  6. $lastname = $_POST['lastname'];
  7. $username = $_POST['username'];
  8. $email = $_POST['email'];
  9. $password = $_POST['password'];
  10. $passwordconfirm = $_POST['passwordconfirm'];
  11. $gender = $_POST['reg_gender'];
  12. $agree = $_POST['agree'];
  13.  
  14. $user = mysqli_query($conn, "SELECT username from users WHERE username = '".$username."'");
  15. $count = mysqli_num_rows($user);
  16.  
  17. if($username =='' || $password =='' || $passwordconfirm =='' || $email =='' || $firstname =='' || $lastname =='' || $gender==''|| $agree =='' ){
  18. echo "Fill out the fields!";
  19. }
  20. else{
  21. if($password != $passwordconfirm){
  22. echo "Password does not match!";
  23. }
  24. else{
  25. if($count != 0){
  26. echo "Username already exists!";
  27. }
  28.  
  29. else{
  30.  
  31. $insert = mysqli_query($conn, "INSERT INTO users VALUES ('','$username','$password','$email','$firstname','$lastname','$gender','$agree')");
  32. if(!$insert){
  33. echo mysqli_errno();
  34. }
  35. else{
  36. echo "Records have been saved!";
  37. }
  38. }
  39. }
  40. }
  41. }
  42. ?>
  43.  
  44. <html>
  45. <!DOCTYPE html>
  46. <html lang="en">
  47.  
  48. <head>
  49. <?php include('header.php'); ?>
  50. </head>
  51.  
  52. <body>
  53. <?php include('navigation.php'); ?>
  54.  
  55.  
  56. <form method="POST" action="signup.php">
  57. <div id="loginsignup">
  58. <!-- LOGIN PAGE -->
  59.  
  60. <!-- REGISTRATION FORM -->
  61. <div class="text-center" style="padding:50px 0">
  62. <div class="logo">register</div>
  63. <!-- Main Form -->
  64. <div class="login-form-1">
  65. <form id="register-form" class="text-left">
  66. <div class="login-form-main-message"></div>
  67. <div class="main-login-form">
  68. <div class="login-group">
  69. <div class="form-group">
  70. <label for="reg_username" class="sr-only">Username</label>
  71. <input type="text" class="form-control" id="reg_username" name="username" placeholder="Username">
  72. </div>
  73. <div class="form-group">
  74. <label for="reg_password" class="sr-only">Password</label>
  75. <input type="password" class="form-control" id="reg_password" name="password" placeholder="Password">
  76. </div>
  77. <div class="form-group">
  78. <label for="reg_password_confirm" class="sr-only">Password Confirm</label>
  79. <input type="password" class="form-control" id="reg_password_confirm" name="passwordconfirm" placeholder="Confirm Password">
  80. </div>
  81.  
  82. <div class="form-group">
  83. <label for="reg_email" class="sr-only">Email</label>
  84. <input type="text" class="form-control" id="reg_email" name="email" placeholder="Email">
  85. </div>
  86. <div class="form-group">
  87. <label for="reg_firstname" class="sr-only">First Name</label>
  88. <input type="text" class="form-control" id="reg_firstname" name="firstname" placeholder="First Name">
  89. </div>
  90.  
  91. <div class="form-group">
  92. <label for="reg_lastname" class="sr-only">Last Name</label>
  93. <input type="text" class="form-control" id="reg_lastname" name="lastname" placeholder="Last Name">
  94. </div>
  95.  
  96. <div class="form-group login-group-checkbox">
  97. <input type="radio" class="" name="reg_gender" id="male" placeholder="username">
  98. <label for="male">Male</label>
  99.  
  100. <input type="radio" class="" name="reg_gender" id="female" placeholder="username">
  101. <label for="female">Female</label>
  102. </div>
  103.  
  104. <div class="form-group login-group-checkbox">
  105. <input type="checkbox" class="tickbox" id="reg_agree" name="agree" value="1"/>
  106. <label for="reg_agree">I agree with terms and conditions <a href="#">terms</a></label>
  107. </div>
  108. </div>
  109. <?php
  110. /* FIELDS ARE STILL EMPTY THIS CODE IS USED FOR HIDING PRECAUTIONAL PHP ERRORS MGS BECAUSE YOURE USING PHP AND HTML FORM IN 1 FILE*/
  111. require_once("connect.php");
  112. // Turn off error reporting
  113. error_reporting(0);
  114. // Report runtime errors
  115. error_reporting(E_ERROR | E_WARNING | E_PARSE);
  116. // Report all errors
  117. error_reporting(E_ALL);
  118. // Same as error_reporting(E_ALL);
  119. ini_set("error_reporting", E_ALL);
  120. // Report all errors except E_NOTICE
  121. error_reporting(E_ALL & ~E_NOTICE);
  122. /* FIELDS ARE STILL EMPTY THIS CODE IS USED FOR HIDING PRECAUTIONAL PHP ERRORS MGS BECAUSE YOURE USING PHP AND HTML FORM IN 1 FILE*/
  123.  
  124.  
  125. /* START */
  126. /* THIS LINE OF CODES , CHECKS WHETHER THERE IS CURRENTLY LOGGED IN USER AND WHETHER
  127. ITS AN ADMIN OR NON ADMIN*/
  128. if(isset($_SESSION['email'])){
  129. if($_SESSION['email']){
  130. $con = mysqli_connect("localhost", "root", "" ,"jono_db") or die("We couldn't connect!");
  131. $query = mysqli_query($con,"SELECT * FROM users WHERE email='".$_SESSION['email']."'");
  132. $numrows = mysqli_num_rows($query);
  133. if($numrows != 0){
  134. while($row = mysqli_fetch_assoc($query)){
  135. $usertype = $row['is_admin'];
  136. if($usertype == 1){
  137. echo'<label>User Type:</label><br/>';
  138. echo'<select name="usertype">';
  139. echo'<option value="1">ADMIN</option>';
  140. echo'<option value="0">NON ADMIN</option>';
  141. echo'</select>';
  142.  
  143. }
  144. else{
  145. header('Location: home.php');
  146. }
  147. }
  148. }
  149. }
  150. }
  151. ?>
  152. <button type="submit" name="submit" class="login-button"><i class="fa fa-chevron-right"></i></button>
  153.  
  154. </div>
  155. <div class="etc-login-form">
  156. <p>Already have an account? <a href="auth.php">Login Here</a></p>
  157. </div>
  158. </form>
  159. </div>
  160. <!-- end:Main Form -->
  161. </div>
  162.  
  163.  
  164. </div>
  165.  
  166. </body>
  167. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement