Advertisement
Guest User

Untitled

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