<?php include_once('config/vdb.php');

if (filter_has_var(INPUT_POST, "submit")) 
try{    
     //   $date =            htmlspecialchars (strtoupper($_POST['date']));
     //   $date =            date("Y-m-d", strtotime($date));

       $today = date("d.m.Y"); 
       $today = date("Y-m-d", strtotime($today));

        // $branch_id =                htmlspecialchars ( $_POST['branch_id']);  
        // $group_id =                htmlspecialchars ( $_POST['group']);  
       $fullname =                htmlspecialchars ( $_POST['fullname']);  
       $fname =               '';   //   htmlspecialchars ( $_POST['fname']);   
       $mname =              '';//      htmlspecialchars ( $_POST['mname']);   
       $lname =               '';//      htmlspecialchars ( $_POST['lname']);  
       $idno =                      htmlspecialchars ( $_POST['idno']);   
       $phone =                     htmlspecialchars ( $_POST['phone']); 
       $email =                     htmlspecialchars ( $_POST['email']); 
      // $pass =                     htmlspecialchars ( $_POST['password']); 

       $vpassword =                 $_POST['password'];    
       $VPassword =                 password_hash($vpassword, PASSWORD_BCRYPT);
           
     
      $sql = 'INSERT INTO clients(date,fullname,fname,mname,lname,idno,phone,email,password )  
                          VALUES(:date,:fullname,:fname,:mname,:lname,:idno,:phone,:email,:pass )';
      $stmt = $conn->prepare($sql)->execute([ 'date'=>$today,'fullname'=>$fullname,'fname'=>$fname,'mname'=>$mname,'lname'=>$lname,
                                              'idno'=>$idno,'phone'=>$phone,'email'=>$email,'pass'=>$VPassword ]);

                                              $inserted = $conn->lastInsertId(); 
                                              
                                              if($inserted>0)
                                                 {
                                                    $msg = true;
                                                  // $Lerror='<div class="alert alert-success alert-dismissable" style="margin-top:5px;"><i class="fa fa-key"></i><button type="button" class="close" data-dismiss="alert" aria-hidden="true">×</button><b> Customer added Succefully  </b></div>';  
                                                   
                                                  }else
                                                   {
                                                     header("location:client.php");
                                                  }
     

       
             if(isset($msg))
            {
             
                $_SESSION['message'] = "Successfully Added";
                header('Location:vlogin.php');
                exit(0);
            }
            else
            {
                $_SESSION['message'] = "unsuccessfull ";
                header('Location:vlogin.php');
                exit(0);
            }

  
  } catch(Exception $e) { echo 'Message: ' .$e->getMessage();}

?>


<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="utf-8">
  <meta content="width=device-width, initial-scale=1.0" name="viewport">
  <title>Book now - Farm Stay Ventures </title>
  <meta name="description" content="">
  <meta name="keywords" content="">
   <?php include_once('inc/link.php'); ?>
   <link href="inc/vis.css" rel="stylesheet">

</head>

<body class="starter-page-page">

  <!-- HEADER-->
     <?php include_once('inc/header.php'); ?>
  <!-- END HEADER-->

  <main class="main">

    <!-- Page Title -->
    <div class="page-title" data-aos="fade" >
      <div class="heading" style="padding-top:20px; background-image: linear-gradient(rgba(45, 166, 63, 0.6) , rgba(255, 34, 255, 0.4) ), 
                 url(img/banner.jpeg)  " >
        <div class="container">
          <div class="row d-flex justify-content-center text-center">
            <div class="col-lg-8">
              <h1> <i class="fa fa-user-plus"></i> Register </h1>
              <!-- <p class="mb-0">Meets the experienced professionals who guide our vision and operations..</p> -->
            </div>
          </div>
        </div>
      </div>
      <!-- <nav class="breadcrumbs">
        <div class="container">
          <ol>
            <li><a href="index.html">Home</a></li>
            <li class="current">Starter Page</li>
          </ol>
        </div>
      </nav> -->
    </div><!-- End Page Title -->

     <!-- Starter Section Section 
     <section id="starter-section" class="starter-section section">

      
      <div class="container section-title" data-aos="fade-up">
        <h2> Our Team </h2>
        <p>Necessitatibus eius consequatur ex aliquid fuga eum quidem sint consectetur velit</p>
      </div>

      <div class="container" data-aos="fade-up">
        <p>Use this page as a starter for your own custom pages.</p>
      </div>

      </section>
        /Starter Section Section -->

     

     <section id="contact" class="contact section">
      <!-- Section Title 
      <div class="container section-title" data-aos="fade-up">
        <h2>Contact</h2>
        <p>Necessitatibus eius consequatur ex aliquid fuga eum quidem sint consectetur velit</p>
      </div>
          End Section Title -->


      <div class="container" data-aos="fade-up" data-aos-delay="100">

        <div class="row ">

           <!--
          <div class="col-lg-5">
            
            <div class="info-item d-flex" data-aos="fade-up" data-aos-delay="300">
              <i class="bi bi-geo-alt flex-shrink-0"></i>
              <div>
                <h3>Location</h3>
                <p>Head Office: Hola, Tana River County, Kenya </p>
              </div>
            </div>
             End Info Item 
     
          </div>
           -->

          
           <div class="col-lg-1"></div>
          

           <div class="col-lg-10">
            <form action=" " method="post"  data-aos="fade-up" data-aos-delay="200">
              <div class="row gy-4">

                <div class="col-md-4">
                  <label> Full Name </label>
                  <input type="text" name="fname" class="form-control" autocomplete="true"  required="">
                </div>
                <!-- <div class="col-md-3">
                  <label> Middle Name </label>
                  <input type="text" name="mname" class="form-control"  autocomplete="true"  required="">
                </div>
                <div class="col-md-3">
                  <label> Last Name </label>
                  <input type="text" name="lname" class="form-control" autocomplete="true"   required="">
                </div> -->
                <div class="col-md-4">
                  <label> Passport/ ID No </label>
                  <input type="text" name="idno" class="form-control"  autocomplete="true"  required="">
                </div>

                <div class="col-md-4">
                  <label> Phone Number </label>
                  <input type="text" name="phone" class="form-control"  autocomplete="true"  required="">
                </div>
                <div class="col-md-4">
                  <label> Email Address  </label>
                  <input type="text" name="email" class="form-control" autocomplete="true"  required="">
                </div>
                <div class="col-md-4">
                  <label> Password  </label>
                  <input type="text" name="password" class="form-control" placeholder="password " required="">
                </div>
                <div class="col-md-4">
                  <label> Re-enter password  </label>
                  <input type="text" name="reenterpassword" class="form-control" placeholder="re-enter password " required="">
                </div>

                <!-- <div class="col-md-12">
                  <input type="text" class="form-control" name="subject" placeholder="Subject" required="">
                </div> -->

            

                <div class="col-md-12 text-center">
                  <!-- <div class="loading">Loading</div>
                  <div class="error-message"></div>
                  <div class="sent-message">Your message has been sent. Thank you!</div> -->

                  <button type="submit" name="submit" class=" btn btn-success bg-maroon " style="border-radius:25px;"> <i class="fa fa-save"></i> Create an account  </button>
                  <hr>
                    <p> Already registered <a href="vlogin"> Log In</a></p>
                </div>
                

              </div>
            </form>
           </div>

           <div class="col-lg-1"></div>
          <!-- End Contact Form -->

        </div>

      </div>

     </section>


  </main>

  <!-- Footer -->
    <?php include_once('inc/footer.php'); ?>
  <!-- End footer -->

  <!-- Scroll Top -->
  <a href="#" id="scroll-top" class="scroll-top d-flex align-items-center justify-content-center"><i class="bi bi-arrow-up-short"></i></a>

  <!-- Preloader -->
  <div id="preloader"></div>

  <!-- Vendor JS Files -->

  <?php include_once('inc/linkjs.php'); ?>



</body>

</html>