Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <form action='register.php' method='post'>
- NIC Number : <select class='drdwn1' name='idtype'>
- <option value="old">Old</option>
- <option value="new">New</option>
- </select>
- <input type='text' name='nic'/>
- Name with Initials : <select class='drdwn1' name='saluation'>
- <option value="Mr.">Mr.</option>
- <option value="Ms.">Ms.</option>
- </select>
- <input type='text' name='name' />
- Address : <input type='text' name='address' />
- Occupation : <input type='text' name='occupation' />
- Contact Number : <input type='text' name='contactno'/>
- Email Address : <input type='text' name='email' placeholder=''/>
- Password : <input type='password' name='password' ></br>
- Confirm Password : <input type='password' name='password1' />
- <input type='submit' name='submit' value='Submit' >
- </form>
- <?
- php
- if (isset($_POST['submit'])){
- $Idtype=$_POST['idtype'];
- $Nic=$_POST['nic'];
- $Saluation=$_POST['saluation'];
- $Name=$_POST['name'];
- $Address=$_POST['address'];
- $Occupation=$_POST['occupation'];
- $Contactno=$_POST['contactno'];
- $Email=$_POST['email'];
- $Username=$_POST['nic'];
- $Password=$_POST['password'];
- $Password1=$_POST['password1'];
- $email = filter_var($Email, FILTER_SANITIZE_EMAIL);
- $check=mysqli_query($conn,"select * from user.admin WHERE username='$Username'");
- $checkrows=mysqli_num_rows($check);
- // Check if User exist
- if($checkrows>0) {
- echo "<p class='msgp1'>Your username already exist!</p>";
- }
- // Check if User exist
- // Check Manditory fields
- else if(empty($_POST['nic'] AND $_POST['email'] AND $_POST['password'])){
- echo "<p class='msgp1'>Please fill the mandetory fields!</p>";
- }
- // Check Manditory fields
- // Validate Email
- else if (!filter_var($email, FILTER_VALIDATE_EMAIL)) {
- echo("<p class='msgp1'>$email is not a valid email address!</p>");
- }
- // Validate Email
- //if old ID and and not filled V
- 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)){
- echo "<p class='msgp1'>Should have the letter V or X at the end!</p>";
- }
- //Validate ID Number
- // Validate Password
- else if(($_POST['password'] !== $_POST['password1'])){
- echo "<p class='msgp1'>Password must mach!</p>";
- }
- // Validate Password
- else{
- $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')";
- if ($conn->query($sql) === TRUE) {
- Echo "Success!";
- }
- }
- }
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement