Advertisement
Guest User

Untitled

a guest
Aug 31st, 2017
134
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.54 KB | None | 0 0
  1. <form action='register.php' method='post'>
  2. NIC Number : <select class='drdwn1' name='idtype'>
  3. <option value="old">Old</option>
  4. <option value="new">New</option>
  5. </select>
  6. <input type='text' name='nic'/>
  7.  
  8. Name with Initials : <select class='drdwn1' name='saluation'>
  9. <option value="Mr.">Mr.</option>
  10. <option value="Ms.">Ms.</option>
  11. </select>
  12.  
  13. <input type='text' name='name' />
  14. Address : <input type='text' name='address' />
  15. Occupation : <input type='text' name='occupation' />
  16. Contact Number : <input type='text' name='contactno'/>
  17. Email Address : <input type='text' name='email' placeholder=''/>
  18. Password : <input type='password' name='password' ></br>
  19. Confirm Password : <input type='password' name='password1' />
  20. <input type='submit' name='submit' value='Submit' >
  21. </form>
  22.  
  23.  
  24.  
  25.  
  26. <?
  27.  
  28. php
  29.  
  30. if (isset($_POST['submit'])){
  31.  
  32. $Idtype=$_POST['idtype'];
  33. $Nic=$_POST['nic'];
  34. $Saluation=$_POST['saluation'];
  35. $Name=$_POST['name'];
  36. $Address=$_POST['address'];
  37. $Occupation=$_POST['occupation'];
  38. $Contactno=$_POST['contactno'];
  39. $Email=$_POST['email'];
  40. $Username=$_POST['nic'];
  41. $Password=$_POST['password'];
  42. $Password1=$_POST['password1'];
  43. $email = filter_var($Email, FILTER_SANITIZE_EMAIL);
  44.  
  45. $check=mysqli_query($conn,"select * from user.admin WHERE username='$Username'");
  46. $checkrows=mysqli_num_rows($check);
  47.  
  48. // Check if User exist
  49. if($checkrows>0) {
  50. echo "<p class='msgp1'>Your username already exist!</p>";
  51. }
  52. // Check if User exist
  53.  
  54. // Check Manditory fields
  55. else if(empty($_POST['nic'] AND $_POST['email'] AND $_POST['password'])){
  56. echo "<p class='msgp1'>Please fill the mandetory fields!</p>";
  57. }
  58. // Check Manditory fields
  59.  
  60. // Validate Email
  61. else if (!filter_var($email, FILTER_VALIDATE_EMAIL)) {
  62. echo("<p class='msgp1'>$email is not a valid email address!</p>");
  63. }
  64. // Validate Email
  65.  
  66. //if old ID and and not filled V
  67. else if (strlen($Nic) == '10' AND !preg_match("/^[0-9]+[0-9]+[0-9]+[0-9]+[0-9]+[0-9]+[0-9]+[0-9]+[0-9]+[V,X]$/i", $Nic)){
  68. echo "<p class='msgp1'>Should have the letter V or X at the end!</p>";
  69. }
  70. //Validate ID Number
  71.  
  72. // Validate Password
  73. else if(($_POST['password'] !== $_POST['password1'])){
  74. echo "<p class='msgp1'>Password must mach!</p>";
  75. }
  76. // Validate Password
  77.  
  78.  
  79. else{
  80.  
  81. $sql = "INSERT INTO user.admin (nic, saluation, name, address, city, bday, occupation, contactno, email, username, password) VALUES ('$Nic','$Saluation','$Name','$Address','$City','$Bday','$Occupation','$Contactno','$Email','$Username','$Password')";
  82. if ($conn->query($sql) === TRUE) {
  83.  
  84. Echo "Success!";
  85. }
  86. }
  87. }
  88.  
  89. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement