Advertisement
Guest User

Untitled

a guest
Mar 24th, 2018
117
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 2.73 KB | None | 0 0
  1. <?php
  2. require 'includes/backbone.php';
  3.         $mainObj = new mainFinger;
  4.         $mainObj->dbcon();
  5.  
  6. include 'includes/header.php';
  7. ?>
  8.     <div class="container">
  9.         <div class="form">
  10.             <h2>Sign In Here</h2>
  11.             <form method="post" action="">
  12.                 <input type="username" name="username" placeholder="Username" required>
  13.                 <input type="password" name="password" placeholder="Password" required>
  14.                 <input type="submit" name="loginbtn" value="Log Me In">
  15.             </form>
  16.         </div>
  17.        
  18.  <?php include 'includes/footer.php'; ?>
  19. <?php
  20. require 'includes/backbone.php';
  21.         $mainObj = new mainFinger;
  22.         $mainObj->dbcon();
  23.  
  24. include 'includes/header.php';
  25. ?>
  26.         <div class="form up">
  27.             <h2>Register Now</h2>
  28.             <form method="post" action="">
  29.                 <input type="text" name="fullname" placeholder="Full Name" required>
  30.                 <input type="text" name="username" placeholder="User Name" required>
  31.                 <input type="email" name="email" placeholder="Email" required>
  32.                 <input type="password" name="password" placeholder="Password" required>
  33.                 <input type="password" name="confirmpass" placeholder="Confirm Password" required>
  34.                 <input type="submit" name="registerbtn" value="Register Me">
  35.  
  36.                 <?php $mainObj->registerUser(); ?>
  37.             </form>
  38.         </div>
  39.     </div>
  40.    
  41.     <?php include 'includes/footer.php'; ?>
  42.  
  43. <?php
  44.  
  45.     class mainFinger{
  46.  
  47.         public $dbHost, $dbUsername, $dbPass, $dbName, $conString, $query;
  48.         public $fullname, $username, $email, $password, $confirmpass, $datenow;
  49.  
  50.         function dbcon(){
  51.             $this->dbHost = "localhost";
  52.             $this->dbUsername = "root";
  53.             $this->dbPass = "";
  54.             $this->dbName = "welcome";
  55.  
  56.             $this->conString = mysqli_connect($this->dbHost, $this->dbUsername, $this->dbPass, $this->dbName);
  57.             if(!$this->conString){
  58.                 echo '<h1> connection to database not successful. </h1>';
  59.             }
  60.         }
  61.  
  62.         function registerUser(){
  63.             if (isset($_POST['registerbtn'])){
  64.                 $this->fullname = $_POST['fullname'];
  65.                 $this->username = $_POST['username'];
  66.                 $this->email = $_POST['email'];
  67.                 $this->password = $_POST['password'];
  68.                 $this->confirmpass = $_POST['confirmpass'];
  69.                 $this->datenow = date("Y m d h:i:s");
  70.  
  71.                 if (empty($this->fullname && $this->username  && $this->email && $this->password)){
  72.                     echo '<div class ="error"> All Fields are required. </div> ';
  73.                 }elseif ($this->password != $this->confirmpass) {
  74.                     echo '<div class ="error"> Password Mismatch</div>';
  75.                 }else{
  76.                     $this->query = "INSERT INTO `welcome` (`fullname`,`username`,`email`,`password`,`reg_date`)
  77.                     values ('$this->fullname','$this->username','$this->email','$this->password','$this->datenow')";
  78.                     if ($this->result = mysqli_query($this->conString, $this->query)){
  79.                         echo "User Creation is successfull";
  80.                     }
  81.                 }
  82.             }
  83.         }
  84.     }
  85. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement