samclarko

reg.php

Jul 17th, 2016
135
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 5.65 KB | None | 0 0
  1. <?php
  2. include 'connect.php';
  3.  
  4. if(isset($_REQUEST['submit'])){
  5.     $fname = $_POST['fname'];
  6.     $lname = $_POST['lname'];
  7.     $other = $_POST['other'];
  8.     $email = $_POST['email'];
  9.     $username = $_POST['username'];
  10.     $password = $_POST['password'];
  11.     $confirmpassword = $_POST['confirmpassword'];
  12.     $gender = $_POST['gender'];
  13.     $dob = $_POST['dob'];
  14.     $address = $_POST['address'];
  15.    
  16.     if(!empty($fname) && !empty($lname) && !empty($other) && !empty($email) && !empty($username) && !empty($password) && !empty($confirmpassword) && !empty($gender) &&
  17.     !empty($dob) && !empty($address)){
  18.        
  19.         if($password == $confirmpassword){
  20.            
  21.             if(strlen($password) < 6 || strlen($password) > 15){
  22.                
  23.                 $message= 'Password must be between 6 and 15 characters ';
  24.                
  25.             }else{
  26.                
  27.                 if(strlen($username) < 4 || strlen($username) > 9){
  28.                    
  29.                     $message= 'Username must be between 4 and 8 characters';
  30.                    
  31.                 }else{
  32.                    
  33.                     if(is_numeric($dob)){
  34.                        
  35.                         $message= 'Date of birth must be numbers';
  36.                        
  37.                     }else{
  38.                        
  39.                         if(strlen($dob)!== 10){
  40.                        
  41.                             $message= 'Date of Birth is Invalid';
  42.                    
  43.                     }else{
  44.                        
  45.                             $query = "INSERT INTO members (fname, lname, other, email, username, password, dob, gender, address) VALUES
  46.                             ('$fname', '$lname', '$other','$email', '$username', '$password', '$dob', '$gender', '$address')";
  47.                            
  48.                                 $db = mysql_query($query);
  49.                                
  50.                                 $message= 'You have been Registered';
  51.                    
  52.                     }      
  53.                        
  54.                     }
  55.                 }
  56.                
  57.             }
  58.                    
  59.         }else{
  60.            
  61.             $message= 'Passwords do not match';
  62.            
  63.         }
  64.        
  65.     }else{
  66.        
  67.         $message= 'All fields are required';
  68.     }
  69. }else{
  70.     $message= "";
  71. }
  72.  
  73. ?>
  74.  
  75. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
  76. <html xmlns="http://www.w3.org/1999/xhtml">
  77. <head>
  78. <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
  79. <title>Register Here</title>
  80. <link rel="stylesheet" href="css/style.css" type="text/css">
  81. </head>
  82.  
  83. <body>
  84. <div  id="container">
  85.         <div class="head">
  86.             School Portal
  87.         </div>
  88.                 <div id="sideleft">
  89.                     <div class="sideleft">
  90.                             <ul>
  91.                                     <li><a href="index.php" title="">Home Page</a></li>
  92.                                     <li><a href="reg.php" title="">Register</a></li>
  93.                                    
  94.                            
  95.                             </ul>
  96.                     </div>
  97.                 </div>
  98.                
  99.                 <div id="sideright";>
  100.                     <h4>Register Here</h4>
  101.                    
  102.                     <form action="reg.php" method="post">
  103.                    
  104.                         <table>
  105.                          <font face="Times New Roman, Times, serif" color="#CC0000"><?php echo $message; ?></font>
  106.                             <tr>
  107.                                 <td>First Name</td>
  108.                                 <td><input type="text" name="fname"></td>
  109.                              </tr>
  110.                              
  111.                              <tr>
  112.                                 <td>Last Name</td>
  113.                                 <td><input type="text" name="lname"></td>
  114.                              </tr>
  115.                              
  116.                              <tr>
  117.                                 <td>Other Name</td>
  118.                                 <td><input type="text" name="other" ></td>
  119.                              </tr>
  120.                              
  121.                              <tr>
  122.                                 <td>Email</td>
  123.                                 <td><input type="email" name="email" ></td>
  124.                              </tr>
  125.                              
  126.                              <tr>
  127.                                 <td>Username</td>
  128.                                 <td><input type="text" name="username" ></td>
  129.                              </tr>
  130.                              
  131.                              <tr>
  132.                                 <td>Pasword</td>
  133.                                 <td><input type="password" name="password" ></td>
  134.                              </tr>
  135.                              
  136.                              <tr>
  137.                                 <td>Confirm Password</td>
  138.                                 <td><input type="password" name="confirmpassword" ></td>
  139.                              </tr>
  140.                              <tr>
  141.                                 <td>Gender</td>
  142.                                 <td><select name="gender" >
  143.                                 <option>----</option>
  144.                                 <option>Male</option>
  145.                                 <option>Female</option>
  146.                                 </select>
  147.                                 </td>
  148.                              </tr>
  149.                              <tr>
  150.                                 <td>Date of Birth</td>
  151.                                 <td><input type="text" name="dob" ></td>
  152.                              </tr>
  153.                              
  154.                              <tr>
  155.                                 <td>Address</td>
  156.                                 <td><textarea  name="address" cols="15" rows="5" >
  157.                                
  158.                                 </textarea></td>
  159.                              </tr>
  160.                              
  161.                              <tr>
  162.                                 <td>&nbsp;</td>
  163.                                 <td><input type="submit" name="submit"  value="Register"></td>
  164.                              </tr>
  165.                       </table>
  166.                  </form>
  167.                 </div>
  168. </div>
  169.  
  170. </body>
  171. </html>
Add Comment
Please, Sign In to add comment