<?php 

session_start();

$msg="";
$msg_cap="";

if(isset($_POST['form_data_insert'])){
	// code for check server side validation
	if(empty($_SESSION['captcha_code']) || strcasecmp($_SESSION['captcha_code'], $_POST['captcha_code']) != 0){  
		$msg_cap="CAPTCHA DID NOT MATCH";// Captcha verification is incorrect.		
	}else{// Captcha verification is Correct. Final Code Execute here!		
		$msg_cap="";		
	}
}	


	require_once("../admin/conn.php");
	require_once("../bll/f_common.php");
	require_once("../bll/public_common.php");


if(isset($_POST['form_data_insert'])){
	
	$msg_class="error";

	if($_POST['mobile_no']=="" || $_POST['otp']=="")
		$msg="এক বা একাধিক তথ্যের ঘর খালি রাখা হয়েছে। অনুগ্রহ করে তথ্যের ঘর সঠিকভাবে পূরণ করুন এবং আবার চেষ্টা করুন। <br>One or more field is missed or left blank. Please fill all field properly and try again.";

	/*duplicate mobile off
	if($_POST['mobile_no']!=''){
		$sql = "SELECT * FROM dixit_registration WHERE mobile_no='".$_POST['mobile_no']."'";
		$query = mysql_query($sql);
		if(mysql_num_rows($query)>0)
			$msg = "দীক্ষিত তথ্য (মোবাইল নম্বর) ইতিমধ্যেই বিদ্যমান।<br>Dixit information (Mobile No) already exists for selected.";
	}
	*/
	
	if(strlen($_POST['mobile_no'])!=11){
		$msg = "মোবাইল নম্বর ১১ সংখ্যার হতে হবে। <br>Mobile number must be 11 digit.";
	}
	if(substr($_POST['mobile_no'],0,3) != "013" and substr($_POST['mobile_no'],0,3) != "017" and substr($_POST['mobile_no'],0,3) != "014" and substr($_POST['mobile_no'],0,3) != "019" and substr($_POST['mobile_no'],0,3) != "015" and substr($_POST['mobile_no'],0,3) != "016" and substr($_POST['mobile_no'],0,3) != "018"){
		$msg = "মোবাইল নম্বর সঠিক নয়। <br>Invalid mobile number.";
	}
	
	$str_mobile = "SELECT * FROM dixit_registration WHERE mobile_no = '".$_POST['mobile_no']."' AND otp  = '".$_POST['otp']."'";
	echo $str_mobile;
	$query_str_mobile=mysql_query($str_mobile);
	if(mysql_num_rows($query_str_mobile)==0){
		$msg = "Verification information not correct.";
	}

	if($msg=='' and $msg_cap==''){
		$condition="mobile_no='".$_POST[mobile_no]."' AND otp='".$_POST[otp]."'";
		unset($_POST['form_data_insert']);
		unset($_POST['otp']);
		$_POST['otp_verified'] = 'Y';
		$_POST['last_update']=date("Y-m-d H:i:s");

		if(update_data_into_table($_POST,"dixit_registration",$condition)){
			$msg_class="success"; //success, error, warn
			
			$sms_text="Joy Guru. Your verification is completed. Thank you. Help Line: 01731293502.";
			
			//sms section start
			
			$number="88".$_POST['mobile_no'];
			$sms_response = sms_send($number, $sms_text);
			$sms_response_code = substr($sms_response, strpos($sms_response,':')+1, strpos($sms_response,',')-strpos($sms_response,':')-1);

			$sms_record_sql = "INSERT INTO sms_dispatch_list VALUES ('0', '" . $sms_response_code . "', '" . $sms_text ."', '" . $number . "', '1', '10002', " . sms_char_len($sms_text, mb_detect_encoding($sms_text)). ", '". $_SESSION['user_id'] . "', '" . $_SESSION['user_id'] . "', NOW(), NOW())";

			//echo $sms_record_sql;

			if(mysql_query($sms_record_sql)){
				//echo "SMS successfully saved.";
			}
			else {
				//echo "SMS faided to save.";
			}

			//sms section ends
			$_POST = reset_default_values();
				header("Location: verified.php");
			}

		else{
			$msg_class="error"; //success, error, warn
			$msg = "Error while inserting dixit information.";
		}
	}
}
elseif(!isset($_REQUEST['eid']))
{
  //default values
  $_POST = reset_default_values();
}

function reset_default_values()
{
  $default_values = array('mobile_no'=>'', 'otp'=>'');
  return $default_values;
}

?>
  <!--A Design by W3layouts
   Author: W3layout
   Author URL: http://w3layouts.com
   License: Creative Commons Attribution 3.0 Unported
   License URL: http://creativecommons.org/licenses/by/3.0/
   -->
<!DOCTYPE html>
<html lang="en">
   
<!-- Mirrored from demo.w3layouts.com/demos_new/template_demo/04-08-2018/summer_camp_form-demo_Free/1603175437/web/index.html by HTTrack Website Copier/3.x [XR&CO'2014], Wed, 22 May 2019 12:50:09 GMT -->
<!-- Added by HTTrack --><meta http-equiv="content-type" content="text/html;charset=UTF-8" /><!-- /Added by HTTrack -->
<head>
		<title>সৎসঙ্গ : Verification</title>
		<!-- Meta tags -->
		<meta name="viewport" content="width=device-width, initial-scale=1" />
		<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
		<meta name="keywords" content=""
		 />
		<script>
		 addEventListener("load", function() { setTimeout(hideURLbar, 0); }, false); function hideURLbar(){ window.scrollTo(0,1); }
		</script>

		<!-- Meta tags -->
		<!-- Calendar -->
		<link rel="stylesheet" href="css/jquery-ui.css" />
		<!-- //Calendar -->
		<!--stylesheets-->
		<link href="css/style.css" rel='stylesheet' type='text/css' media="all">
		<!--//style sheet end here-->
		<!-- Google fonts here-->
		<link href="http://fonts.googleapis.com/css?family=Barlow:300,400,500" rel="stylesheet">
		<link href="http://fonts.googleapis.com/css?family=Josefin+Sans:300,400,600,700" rel="stylesheet">
		<!--//Google fonts here-->
		<link rel="stylesheet" href="css/jquery-ui.css">
		<link rel="stylesheet" href="css/style.css">
		<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.4.1/jquery.min.js"></script>
		<script src="https://code.jquery.com/jquery-3.6.0.js"></script>
		<link rel="stylesheet" href="//code.jquery.com/ui/1.13.1/themes/base/jquery-ui.css">
		<link rel="stylesheet" href="/resources/demos/style.css">
		<script src="https://code.jquery.com/jquery-3.6.0.js"></script>
		<script src="https://code.jquery.com/ui/1.13.1/jquery-ui.js"></script>
		
		<script>
			$(document).ready(function(){
				$('#district').on('change', function(){
					var districtId = $(this).val();
					if(districtId){
						$.ajax({
							type:'POST',
							url:'ajaxData.php',
							data:'district='+districtId,
							success:function(html){
								$('#police_station').html(html);
								$('#post_office').html('<option value="">Select Police Station First</option>'); 
							}
						}); 
					}else{
						$('#police_station').html('<option value="">Select District First</option>');
						$('#post_office').html('<option value="">Select Police Station First</option>'); 
					}
				});

				$('#police_station').on('change', function(){
					var police_stationID = $(this).val();
					if(police_stationID){
						$.ajax({
							type:'POST',
							url:'ajaxData.php',
							data:'police_station='+police_stationID,
							success:function(html){
								$('#post_office').html(html);
							}
						}); 
					}else{
						$('#post_office').html('<option value="">Select Police Station First</option>'); 
					}
				});
				
				$('#post_code').on('blur',function(){
					var post_codeID = $(this).val();
					if(post_codeID){
						$.ajax({
							type:'POST',
							url:'ajaxDataPS.php',
							data:'post_code='+post_codeID,
							success:function(html){
								$('#police_station').html(html);
							}
						}); 
						$.ajax({
							type:'POST',
							url:'ajaxDataPO.php',
							data:'post_code='+post_codeID,
							success:function(html){
								$('#post_office').html(html);
							}
						});
						$.ajax({
							type:'POST',
							url:'ajaxDataDist.php',
							data:'post_code='+post_codeID,
							success:function(html){
								//window.alert(html);
								//$('#district').val(14);    //AMINUL 1
								//$('#district').val(html);  //AMINUL 2
								//var dist_code = Number(html);
								$('#district').val(Number(html));
								//$("#district").val(html).attr('selected',true);
								//$('#district option[value="14"]').attr('selected',true);
							}
						}); 
					}
				});
			});
			
			function post_code_load()
			{
				var post_code_id=document.getElementById( "post_office" );

				if(post_code_id)
				{
				 //window.alert("sometext");
					$.ajax({
						type: 'post',
						url: 'ajaxData.php',
						data: {
						id:post_code_id.value
						},
							success: function (response) {
							$( '#post_code' ).val(response);
						}
					});
				}
			}
			
			$(function() {
				$( "#datepicker1" ).datepicker({
					changeMonth: true,
					changeYear: true,
					showAnim: 'slideDown',
					duration: 'fast',
					dateFormat: 'yy-mm-dd',
					yearRange: "-100:+0"
				});
			});
			$(function() {
				$( "#datepicker2" ).datepicker({
					changeMonth: true,
					changeYear: true,
					showAnim: 'slideDown',
					duration: 'fast',
					dateFormat: 'yy-mm-dd',
					yearRange: "-100:+0"
				});
			});
			
		</script>
		<script type='text/javascript'>
			function refreshCaptcha(){
				var img = document.images['captchaimg'];
				img.src = img.src.substring(0,img.src.lastIndexOf("?"))+"?rand="+Math.random()*1000;
			}
		</script>
</head>
<link href="css/main.css" rel="stylesheet" media="all">
<body>
      <h1 class="header-w3ls">
         দীক্ষিত রেজিস্ট্রেশন 
      </h1>
	  <!---728x90--->

      <!-- multistep form -->
      <div class="main-bothside">
         <form name="frm_admin" id="frm_admin" method="post" action="<?php echo $current_page_name;if(isset($_REQUEST["eid"]) && strlen($_REQUEST["eid"]) > 0) echo "?eid=".$_REQUEST["eid"];?>" enctype="multipart/form-data" class="fields">
            <div class="main-title">
               <h2>Verification</h2>
            </div>
			<!---728x90--->
            <div class="form-group">
				<?php if($msg!=""){ ?>
				<div class="msg <?php echo $msg_class;?>"><?php echo $msg;?></div>
				<?php } ?>
			</div>
            <div class="form-group">
               <div class="form-grid-w3ls">
                  <input type="text" class="form-control" placeholder="Mobile No *" required="" name="mobile_no" value="<?php echo $_POST['mobile_no'];?>">
               </div>
               <div class="form-grid-w3ls">
                  <input type="text" class="form-control" placeholder="Verification Code *" required="" name="otp" value="<?php echo $_POST['otp'];?>">
               </div>
            </div>
            <div class="main-title">
               <h2>Captcha</h2>
            </div>
            <div class="form-group">
               <div class="form-grid-w3ls">
					<?php if(isset($msg)){?>
					<?php echo $msg_cap;?>
					<?php } ?>
					<img src="captcha.php" id='captchaimg'>পাশের লেখাটি নিচে লিখুন <input id="captcha_code" name="captcha_code" type="text">
			   </div>
			</div>
            <input type="submit" value="Submit" name="form_data_insert" onclick="return validate();" class="button1">
         </form>
      </div>
	  <!---728x90--->

      <div class="copy">
         <p>©2024 SATSANG BANGALDESH</p>
      </div>
      <!-- js -->
      
      <!-- //Calendar -->
   </body>

<!-- Mirrored from demo.w3layouts.com/demos_new/template_demo/04-08-2018/summer_camp_form-demo_Free/1603175437/web/index.html by HTTrack Website Copier/3.x [XR&CO'2014], Wed, 22 May 2019 12:50:16 GMT -->
</html>