<?php
include('includes/config.php');
if (isset($_POST['reg']) && $_POST['reg'] == "ahkweb"  ) {
  
  $name = mysqli_real_escape_string($conn, $_POST['name']);
  $phone = mysqli_real_escape_string($conn, $_POST['phone']);
  $email = mysqli_real_escape_string($conn, $_POST['email']);
  $profilepic = mysqli_real_escape_string($conn, $_POST['profilepic']);
  $password = mysqli_real_escape_string($conn, $_POST['password']);
  $cpassword = mysqli_real_escape_string($conn, $_POST['cpassword']);
  $usertype = mysqli_real_escape_string($conn, $_POST['usertype']);
   $createdby = mysqli_real_escape_string($conn, $_POST['createdby']);
 
  
  
  $order_id = "CSCUCL@".rand(000000,999999);
$amount =100;
    if($usertype == "OPERATOR"){
        $amount = 100;
    }else if($usertype == "DISTRIBUTOR"){
        $amount = 300;
    }else{
        $amount = 300;
    }
  if (!empty($password) && !empty($cpassword) && $phone != "ADMIN" && $email != "ADMIN") {
    if ($password == $cpassword) {

      $fpassword = password_hash($cpassword, PASSWORD_DEFAULT);
      $checksql = mysqli_query($conn, "SELECT * FROM usertable WHERE emailid='$email' OR phone='$phone'");
      if (
        !empty($name) &&
        !empty($phone) &&
        !empty($email) &&
        !empty($password) &&
        !empty($cpassword)
      ) {
        if (mysqli_num_rows($checksql) == 0) {
    
          $sql = "INSERT INTO `usertable` (`phone`, `emailid`, `name`,`psaid`,`cprize`, `password`, `city`, `state`, `userid`, `status`, `profilepic`, `createdby`, `joineddate`, `joinedtime`, `usertype`, `walletamount`,`otp`) VALUES ('$phone', '$email', '$name','NOT ALOTED', '98',  '$fpassword', 'cc', 'sdds', '$customer_mobile', 'verified', '$profilepic', null, '', '', '$usertype', '0','');";
          $res = mysqli_query($conn,$sql);
          // 
          }
          if($res){
                  
                if($_POST['mode'] == "qr"){
                        // QR Code Start Here 
                        date_default_timezone_set("Asia/Kolkata");
                        $date = date("d-m-Y");
                        $ins = mysqli_query($conn,"INSERT INTO `wallet`(`phone`,`amount`,`txn_id`,`email`,`status`,`date`,`PAYMENTMODE`) VALUES ('$phone','$amount','$order_id','$email','pending','$date','REGQR')");
                             ?>
                    <form class="mt-2" method="post" name="f2" action="regpg.php">
                        <input type="hidden" name="frompage" value="reg">
                    <input  type="hidden" name="order_id"  value="<?php echo $order_id; ?>">
                    <input type="hidden"  name="phone" value="<?php echo $phone; ?>">
                    <input type="hidden" name="amount" value="<?php echo $amount; ?>">
                    </form>
                    <script type="text/javascript">
                    document.f2.submit();
                    </script>
                        <?php 
                        
                        // QR Code END Here 
                    }
                    
                   
                }
            }else{
                ?>
                <script>
                    $(function(){
                        Swal.fire(
                            'Opps!',
                            'Confirm password Not Match',
                            'error'
                        )
                    })
                </script>
                <?php 
            }

        }else{
            ?>
            <script>
                $(function(){
                    Swal.fire(
                        'Opps',
                        'Your Email or Phone Already Exist',
                        'error'
                    )
                })
            </script>
            <?php 
        }
        
    }
}
if(isset($_POST['successmsg']) && $_POST['successmsg'] == "true"){
    ?>
      <script>
                        $(function(){
                            Swal.fire(
                                'Success!',
                                'Your Account Created Successfully!',
                                'success'
                            )
                        })
                    </script>
    <?php
}
if(isset($_POST['failedmsg']) && $_POST['failedmsg'] == "true"){
    ?>
    <script>
        $(function(){
            Swal.fire(
                'Payment Added Failed',
                'if Payment Deduct Then Contact us!',
                'error'
            )
        })
    </script>
    <?php
}
// UPI message
// UPI Code Success 
if(isset($_POST['success']) && $_POST['success'] == "true"){
    ?>
    <script>
        $(function(){
            Swal.fire(
                'Great',
                'Your Account Created Successfully!',
                'success'
            )
        })
    </script>
    <?php
}
if(isset($_POST['failed']) && $_POST['failed'] == "true"){
    ?>
    <script>
        $(function(){
            Swal.fire(
                'Payment Added Failed',
                'if Payment Deduct Then Contact us!',
                'error'
            )
        })
    </script>
    <?php
}
?>

<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="utf-8">
    <title><?php echo $ahkweb['name'] ?>| REGISTER</title>
    <meta content="width=device-width, initial-scale=1.0" name="viewport">
    <meta content="" name="keywords">
    <meta content="" name="description">

    <!-- Favicon -->
    <link href="img/favicon.ico" rel="icon">

    <!-- Google Web Fonts -->
    <link rel="preconnect" href="https://fonts.googleapis.com">
    <link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
    <link href="https://fonts.googleapis.com/css2?family=Heebo:wght@400;500&family=Roboto:wght@400;500;700&display=swap" rel="stylesheet"> 

    <!-- Icon Font Stylesheet -->
    <link href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/5.10.0/css/all.min.css" rel="stylesheet">
    <link href="https://cdn.jsdelivr.net/npm/bootstrap-icons@1.4.1/font/bootstrap-icons.css" rel="stylesheet">

    <!-- Libraries Stylesheet -->
    <link href="lib/animate/animate.min.css" rel="stylesheet">
    <link href="lib/owlcarousel/assets/owl.carousel.min.css" rel="stylesheet">
    <link href="lib/lightbox/css/lightbox.min.css" rel="stylesheet">

    <!-- Customized Bootstrap Stylesheet -->
    <link href="css/bootstrap.min.css" rel="stylesheet">

    <!-- Template Stylesheet -->
    <link href="css/style.css" rel="stylesheet">
</head>

<body>



        
        <!-- Navbar & Hero End -->


        <!-- Full Screen Search Start -->
       
               
        <!-- Full Screen Search End -->


        <!-- Contact Start -->
        <div class="container-xxl py-5">
         
         <div class="row g-5">
         <div class="col-lg-6">
            
             <img class="img-fluid wow zoomIn" data-wow-delay="0.5s" src="https://i.pinimg.com/originals/4a/e3/ab/4ae3ab78891ac325f6400e3a4273b106.gif" style="visibility: visible; animation-delay: 0.5s; animation-name: zoomIn;">
             <br><hr>
             <img class="img-fluid wow zoomIn" data-wow-delay="0.5s" src="https://i0.wp.com/blog.bankbazaar.com/wp-content/uploads/2019/01/How-to-lock-your-biometrics-for-Aadhaar-security-.gif?fit=1078%2C516&ssl=1" style="visibility: visible; animation-delay: 0.5s; animation-name: zoomIn;">
                 
             </div>
             <div class="col-lg-6 wow fadeInUp" data-wow-delay="0.1s">
                 <div class="section-title position-relative mb-4 pb-2">
                     <h6 class="position-relative text-danger ps-4">ℂ𝕊ℂ 𝕌ℂ𝕃 𝕊𝔼ℝ𝕍𝕀ℂ𝔼𝕊</h6>
                     <h2 class="mt-2">CSC UCL REGISTRAION FORM</h2>
                 </div>
                 <p class="mb-4">.</p>
                
                 <form action="" method="POST">
                         <div class="row g-3">
                             <div class="col-md-12">
                                 <div class="form-floating"> 
                                 <input type="hidden" name="reg" value="ahkweb">
                                     <input type="text" class="form-control" style="text-transform:uppercase" id="name" name="name" placeholder="Your Name"required="" >
                                     <label for="name">Your Name</label>
                                 </div>
                             </div>
                             
                             <div class="col-12">
                                 <div class="form-floating">
                                     <input type="number" class="form-control" id="phone" name="phone" placeholder="Your Email" required="">
                                     <label for="Mobie No">Phone No</label>
                                 </div>
                             </div>
                              <div class="col-12">
                                 <div class="form-floating" style="display: none;">
                                     <input type="createdby" class="form-control" style="text-transform:uppercase" id="createdby" name="createdby" value="u459483528_tiranga1">
                                     <label for="createdby"> createdby</label>
                                 </div>
                             </div>
                             <div class="col-12">
                                 <div class="form-floating">
                                     <input type="email" class="form-control" style="text-transform:uppercase" id="email" name="email" placeholder="Your Email Id">
                                     <label for="email">Email Id</label>
                                 </div>
                             </div>
                             <div class="col-12">
                                 <div class="form-floating">
                                     <input type="text" class="form-control" id="order_id" name="order_id" placeholder="Username will be auto-generated" value=""  required>
                                     <label for="order_id">Username</label>
                                 </div>
                             </div>
                             <div class="col-md-6">
                                 <div class="form-floating">
                                     <input type="passwoard" class="form-control" style="text-transform:uppercase" id="password" name="password" placeholder="password" required="" >
                                     <label for="password">Passwoard</label>
                                 </div>
                             </div>
                             <div class="col-md-6">
                                 <div class="form-floating">
                                     <input type="cpassword" class="form-control" style="text-transform:uppercase" id="cpassword" name="cpassword" placeholder="conform password" required="" >
                                     <label for="email">Conform Passwoard</label>
                                 </div>
                             </div>
                             <div class="col-12">
												<label for="inputSelectCountry" class="form-label">User Type</label>
												<select  required name="usertype" class="form-select" id="inputSelectCountry" aria-label="Default select example">
													<option value="">Please Select</option>
													<option value="OPERATOR">Retailer - 100/- (Lifetime Valid)</option>
													<option value="DISTRIBUTOR">Distributor - 300/- (Unlimited Retailer)</option>
													
												</select>
											</div>
											<div class="col-12">
												<label for="inputSelectCountry" class="form-label">Select Payment Mode</label>
												<select  required name="mode" class="form-select" id="inputSelectCountry" aria-label="Default select example">
												
											
														
															<option value="qr">Payment Gateway</option>
														
													
												</select>
											</div>
                        
                             <div class="col-12">
                                 <button class="btn btn-success w-100 py-3" type="submit">Register</button>
                             </div>
                         </div>
                     </form>
                     <div class="col-12">
                                 <a class="btn btn-danger w-100 py-3" href="login.php">Already Register - Login Now!</a>
                             </div>
                     <div class="d-flex align-items-center mt-4">
                     
                     <a class="btn btn-outline-warning btn-square me-3" href="https://wa.me/message/TWDSMYLVPPRUO1"><i class="fa-brands fa-whatsapp"></i></a>
                     <a class="btn btn-outline-info btn-square me-3" href="https://wa.me/?text=Hello%20Sir!%20"><i class="fab fa-facebook-f"></i></a>
                     <a class="btn btn-outline-success btn-square me-3" href="https://wa.me/?text=Hello%20Sir!%20"><i class="fab fa-instagram"></i></a>
                     <a class="btn btn-outline-primary btn-square" href="https://wa.me/?text=Hello%20Sir!%20"><i class="fab fa-twitter"></i></a>
                 </div>
                 </div>
                
        <!-- Contact End -->
        
        <script>
function readURL(input) {
    if (input.files && input.files[0]) {
        var reader = new FileReader();

        reader.onload = function (e) {
            $('#blah').attr('src', e.target.result);
        }

        reader.readAsDataURL(input.files[0]);
    }
}
$("#blah").hide();
$("#profilepic").change(function(){
    readURL(this);
	$("#blah").show();
});	


function readURLs(input) {
    if (input.files && input.files[0]) {
        var reader = new FileReader();

        reader.onload = function (e) {
            $('#blahs').attr('src', e.target.result);
        }

        reader.readAsDataURL(input.files[0]);
    }
}
$("#blahs").hide();
$("#signInp").change(function(){
    readURLs(this);
	$("#blahs").show();
});
</script>

        <?php
include('footer.php');
?>

        <!-- Footer Start -->
       