Advertisement
Guest User

Untitled

a guest
Nov 23rd, 2016
104
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.02 KB | None | 0 0
  1. <?php
  2. if(isset($_POST['submit'])){
  3. include 'db.php';
  4.  
  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. $age = $_POST['age'];
  12. $address = $_POST['address'];
  13. $gender = $_POST['gender'];
  14. $course = $_POST['course'];
  15. $occupation = $_POST['occupation'];
  16.  
  17. $user = mysqli_query($conn, "SELECT username from users WHERE username = '$username'");
  18. $count = mysqli_num_rows($user);
  19.  
  20. $email = mysqli_query($conn, "SELECT email from users WHERE email = '$email'");
  21. $count2 = mysqli_num_rows($email);
  22.  
  23. if($firstname =='' || $lastname =='' || $username =='' || $email =='' || $password =='' || $passwordconfirm =='' || $age =='' || $address =='' || $gender =='' || $course =='' || $occupation =='' ){
  24. echo "Please fill out the fields!";
  25. }
  26. else if($password != $passwordconfirm) {
  27. echo "Password does not match!";
  28. }
  29. else if($count != 0){
  30. echo "Username already exist!";
  31. }
  32. else if($count2 != 0){
  33. echo "Email already taken!";
  34. }
  35. else{
  36.  
  37. $insert = mysqli_query($conn, "INSERT INTO `users` (`firstname`,`lastname`,`username`,`email`,`password`,`age`,`address`,`gender`,`course`,`occupation`) VALUES ('$firstname','$lastname','$username','$email','$password','$age','$address','$gender','$course','$occupation')");
  38. $result = mysqli_query($conn, $insert);
  39.  
  40. if(!$result){
  41. echo mysqli_errno();
  42. }
  43. else{
  44. echo "Succesfully Registered!";
  45. }
  46. }
  47. }
  48.  
  49.  
  50.  
  51. ?>
  52.  
  53. <html>
  54. <head><title>Registration Form</title></head>
  55. <h1>Sign Up</h1>
  56. <body>
  57. <form method="POST" >
  58. First Name: <input type=text name=firstname pattern="[A-Za-z]+" placeholder="Enter your first name" required /> <br>
  59. Last Name: <input type=text name=lastname pattern="[A-Za-z]+" placeholder="Enter your last name" required /> <br>
  60. Username: <input type=text name=username pattern="[A-Za-z0-9]+" placeholder="Enter your username" required /> <br>
  61. Email: <input name="email" type="email" pattern="[A-Za-z0-9._%+-]+@[A-Za-z0-9.-]+\.[A-Za-z]{1,63}$" placeholder="Email*" id="email" required /> <br>
  62. Password: <input type=password name=password pattern="[A-Za-z0-9]+" placeholder="Enter your password" /> <br>
  63. Confirm Password: <input type=password name=passwordconfirm pattern="[A-Za-z0-9]+" placeholder="Confirm your password" required /> <br>
  64. Age: <input type=text name=age pattern="[0-9]+" placeholder="Age" required /> <br>
  65. Home Address: <input type=text name=address placeholder="Enter your home address" required /> <br>
  66. Gender: <input type=radio name=gender value=male />Male <input type=radio name=gender value=female />Female <br>
  67. Course: <select name=course >
  68. <option>IT</option>
  69. <option>OM</option>
  70. <option>MKT</option>
  71. <option>FM</option>
  72. </select><br>
  73. Occupation: <select name=occupation >
  74. <option>Student</option>
  75. <option>Employed</option>
  76. <option>Unemployed</option>
  77. </select><br>
  78. <input type=submit name=submit value=submit />
  79.  
  80.  
  81.  
  82.  
  83.  
  84. </form>
  85. </body>
  86.  
  87. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement