Advertisement
Guest User

Untitled

a guest
Mar 9th, 2019
144
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 4.01 KB | None | 0 0
  1. <!DOCTYPE html>
  2. <html lang"en">
  3. <body>
  4. <header>
  5.     <div class="container">
  6.         <div id="branding">
  7.         <h1><img src="Kenya_Police_Flag.png" style="width:120px;height:90px;"/><span class="highlight"> CRIME RECORDING SYSTEM <img src="kenyalo.png" style="width:110px;height:90px; float:right; padding-left:180px;"></h1>
  8.         </div>
  9.        
  10.     </div>
  11. </header>  
  12.         <section id="main">
  13.             <div class="container">
  14.                 <article id="main-col"></article>
  15.                    
  16.  
  17. <meta charset="utf-8">
  18. <meta name="viewport" content="width=device-width">
  19. <link rel="stylesheet" href="./css/style.css">
  20.  
  21. <style>
  22. button{
  23. height:38px;
  24.     background:#e8491d;
  25.     border:0;
  26.     padding-left: 20px;
  27.     padding-right: 20px;
  28.     color:#ffffff;
  29.     margin-right: -190px;
  30.     margin-top: 50px;
  31.     display:inline-block;
  32.   }
  33. label
  34. {
  35.  margin-right: 15px;
  36.  margin-top: 5px;
  37.  display:inline-block;
  38. }
  39. </style>
  40.  
  41. <body style="background-color:#bdc3c7;">
  42.     <div id="main-wrapper">
  43.     <center><h2>REGISTRATION FORM</h2></center>
  44.  
  45.         <form action="<?php echo $_SERVER['PHP_SELF']; ?>" method="post">
  46.            
  47.             <div class="inner_container">
  48.                 <center><label>Badge number</label>
  49.                 <input type="text" placeholder="Enter Badge number" name="badge_no" required></br></center>
  50.                 </br>
  51.                
  52.                 <center><label>Name</label>
  53.                 <input type="text" placeholder="Enter Name" name="name" required></br></center>
  54.                 </br>
  55.                
  56.                 <center><label>Date Of Birth</label>
  57.                 <input type="date" placeholder ="Enter Date of Birth" name="dateofbirth" required></br></center>
  58.                 </br>
  59.                
  60.                 <center><label>Jurisdiction</label>
  61.                 <input type="text" placeholder ="Enter Jurisdiction" name="jurisdiction" required></br></center>
  62.                 </br>
  63.                
  64.                 <center><label>Username</label>
  65.                 <input type="text" placeholder ="Enter Username" name="username" required></br></center>
  66.                 </br>
  67.                
  68.                 <center><label>Password</label>
  69.                 <input type="password" placeholder="Enter Password" name="password" required></br></center>
  70.                 </br>
  71.                
  72.                 <center><label>Confirm Password</label>
  73.                 <input type="password" placeholder="Enter Password" name="cpassword" required></br></center>
  74.                 </br>
  75.                
  76.                 <center><button name="register" class="sign_up_btn" type="submit">Register</button></br></center>
  77.                 </br>
  78.                
  79.                 <a href="loginPolice.php"><button type="button" class="back_btn"><< Back to Login</button></a></br>
  80.             </div>
  81.         </form>
  82. <?php
  83.    $con=mysqli_connect("localhost","root","90293269","crime_recording_system");
  84.   if(!$con){
  85.     die('Could not connect: '.mysqli_error());
  86.   }
  87.  
  88.             if(isset($_POST['register']))
  89.             {
  90.                 $badge_no=$_POST['badge_no'];
  91.                 $officer_name=$_POST['name'];
  92.                 $officer_dob=$_POST['dateofbirth'];
  93.                 $jurisdiction=$_POST['jurisdiction'];  
  94.                 $username=$_POST['username'];
  95.                 $opassword=$_POST ['password'];
  96.                 $ocpassword=$_POST['cpassword'];
  97.                
  98.                 $password = hash('sha256', $_POST ['password']);
  99.                 $cpassword = hash('sha256', $_POST ['cpassword']);
  100.                
  101.                
  102.                
  103.                 if($password==$cpassword)
  104.                 {
  105.                 $query = "SELECT * from `login` WHERE `username`='$username'";
  106.                 $query_run = mysqli_query($con,$query);
  107.                         if(mysqli_num_rows($query_run)>0)
  108.                         {
  109.                             echo '<script type="text/javascript">alert("This Username Already exists.. Please try another username!")</script>';
  110.                         }
  111.                         else
  112.                         {
  113.                             $query = "INSERT INTO `officer` (`badge_no`,`officer_name`,`officer_dob`,`jurisdiction`,`username`,`password`) VALUES (`$badge_no`,`$officer_name`,`$officer_dob`,`$jurisdiction`,`$username`, `$password`)";
  114.                             $query_run = mysqli_query($con,$query);
  115.                             if($query_run)
  116.                             {
  117.                                 echo '<script type="text/javascript">alert("User Registered.. Welcome")</script>';
  118.                             }
  119.                             else
  120.                             {
  121.                                 echo '<script type="text/javascript"> alert("Error..")</script>';
  122.                             }
  123.                         }
  124.                     }
  125.                 else
  126.                 {
  127.                     echo '<script type="text/javascript">alert("Password and Confirm Password do not match")</script>';
  128.                 }        
  129.             }
  130.             else
  131.             {
  132.                
  133.             }
  134.         ?>
  135.     </div>
  136. </body>
  137. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement