<?php
session_start();
include_once 'function.php';

//====================================================== Insert ==================================================//

if ($_POST['add'] == 'Sign up')
{
    
    $mobile_no=$_POST['mobile_no'];
    $email=$_POST['email'];
    $user_name=$_POST['user_name'];
	$password=$_POST['password'];

$res=mysqli_query($connect,"SELECT reg_id,reg_mailid, reg_password FROM reg_user WHERE reg_mailid='$email'");
$row=mysqli_fetch_array($res);
$reg_id = $row['reg_id'];
$user_count = mysqli_num_rows($res); // if uname/pass correct it returns must be 1 row

if($user_count == 1 && $row['reg_mailid']== $email && $row['reg_password']== $password)
{
	echo "<script type='text/javascript'>alert('Email Already Registerted.. Goto Login')</script>";
    echo "<script type='text/javascript'>window.location = 'regadd.php'</script>";
}
else{
    
	mysqli_query($connect,"INSERT INTO `reg_user`(`reg_phone`,`reg_name`,`reg_mailid`, `reg_password`) VALUES ('$mobile_no','$user_name', '$email', '$password')") or die(mysqli_error());
	if(($user_count!=1)){
	echo "<div style='width: 350px; text-align: center; color:white; margin: 20% auto 0px; font-family: arial; font-size: 14px; border: 1px solid white; padding: 20px 40px;'>
	Please wait while we update loading...</div>";  
	echo "<script type='text/javascript'>window.location = 'home.php'</script>";
	}
	else{
		echo "<div style='width: 350px; text-align: center; color:white; margin: 20% auto 0px; font-family: arial; font-size: 14px; border: 1px solid white; padding: 20px 40px;'>
	Please wait while we update loading...</div>";  
	echo "<script type='text/javascript'>window.location = 'regadd.php'</script>";
	}
	
	}
}

?>
<!DOCTYPE html>
<html lang="en">
<meta http-equiv="content-type" content="text/html;charset=UTF-8" />   
<head>
<meta charset="utf-8" />
<title>Product Add | <?php echo $site_title; ?></title>
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta content="width=device-width, initial-scale=1" name="viewport" />
<meta content="" name="description" />
<meta content="" name="author" />
<!-- BEGIN GLOBAL MANDATORY STYLES -->
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css">
<link rel="stylesheet" href="assets/font-awesome/font-awesome.min.css">
<link href="http://fonts.googleapis.com/css?family=Open+Sans:400,300,600,700&amp;subset=all" rel="stylesheet" type="text/css" />
<link href="assets/global/plugins/font-awesome/css/font-awesome.min.css" rel="stylesheet" type="text/css" />
<link href="assets/global/plugins/simple-line-icons/simple-line-icons.min.css" rel="stylesheet" type="text/css" />
<link href="assets/global/plugins/bootstrap/css/bootstrap.min.css" rel="stylesheet" type="text/css" />
<link href="assets/global/plugins/bootstrap-switch/css/bootstrap-switch.min.css" rel="stylesheet" type="text/css" />
<script src="//cdn.ckeditor.com/4.5.7/standard/ckeditor.js"></script>
<!-- END GLOBAL MANDATORY STYLES -->
<!-- BEGIN PAGE LEVEL PLUGINS -->
<link href="assets/global/plugins/datatables/datatables.min.css" rel="stylesheet" type="text/css" />
<link href="assets/global/plugins/datatables/plugins/bootstrap/datatables.bootstrap.css" rel="stylesheet" type="text/css" />
<!-- END PAGE LEVEL PLUGINS -->
<!-- BEGIN THEME GLOBAL STYLES -->
<link href="assets/global/css/components.min.css" rel="stylesheet" id="style_components" type="text/css" />
<link href="assets/global/css/plugins.min.css" rel="stylesheet" type="text/css" />
<!-- END THEME GLOBAL STYLES -->
<!-- BEGIN THEME LAYOUT STYLES -->
<link href="assets/layouts/layout/css/layout.min.css" rel="stylesheet" type="text/css" />
<link href="assets/layouts/layout/css/themes/darkblue.min.css" rel="stylesheet" type="text/css" id="style_color" />
<link href="assets/layouts/layout/css/custom.min.css" rel="stylesheet" type="text/css" />
<link href="assets/global/plugins/select2/css/select2.min.css" rel="stylesheet" type="text/css" />
<link href="assets/global/plugins/select2/css/select2-bootstrap.min.css" rel="stylesheet" type="text/css" />
<link href="assets/global/plugins/bootstrap-fileinput/bootstrap-fileinput.css" rel="stylesheet" type="text/css" />
<link href="assets/global/plugins/select2/css/select2.min.css" rel="stylesheet" type="text/css" />
<link href="assets/global/plugins/select2/css/select2-bootstrap.min.css" rel="stylesheet" type="text/css" />
<link href="assets/layouts/customer.css" rel="stylesheet" type="text/css" />
<!-- END PAGE LEVEL PLUGINS -->
<style type="text/css">
.dt-buttons {
display: none;
}
</style>
<script type="text/javascript">
function delete_menu(idurl)
{
go_on = confirm("Are you sure ? ");
if(go_on)
{
document.location.href=idurl;
}
}
</script>
</head>
<!-- END HEAD -->

<body class="page-header-fixed page-sidebar-closed-hide-logo page-content-white">
<div class="page-wrapper">
<!-- BEGIN HEADER -->
<?php include("header.php");?>
<!-- END HEADER -->
<!-- BEGIN HEADER & CONTENT DIVIDER -->
<div class="clearfix"> </div>
<!-- END HEADER & CONTENT DIVIDER -->
<!-- BEGIN CONTAINER -->
<div class="page-container">
<!-- BEGIN SIDEBAR -->
<?php include("menu.php");?>

<!-- END SIDEBAR -->
<!-- BEGIN CONTENT -->
<div class="page-content-wrapper">
<!-- BEGIN CONTENT BODY -->
<div class="page-content">

<!-- END THEME PANEL -->
<!-- BEGIN PAGE BAR -->
<div class="page-bar">
<ul class="page-breadcrumb">
<li>
<a href="index.php">Home</a>
<i class="fa fa-circle"></i>
</li>
<li>
<span>reg Add</span>
</li>
</ul>
<div class="page-toolbar">
<div id="dashboard-report-range" class="pull-right tooltips btn btn-sm" data-container="body" data-placement="bottom" data-original-title="Change dashboard date range">
<i class="icon-calendar"></i>&nbsp;
<span class="thin uppercase hidden-xs"></span>&nbsp;
<i class="fa fa-angle-down"></i>
</div>
</div>
</div>
<!-- END PAGE BAR -->
<!-- BEGIN PAGE TITLE-->

<div class="row">
<div class="col-md-12">
<!-- BEGIN VALIDATION STATES-->
<div class="portlet light portlet-fit portlet-form bordered">
<div class="portlet-title">
<div class="caption">
<i class="fa fa-list  font-red" aria-hidden="true"></i>
<span class="caption-subject font-red sbold uppercase">ADD </span>
</div>
</div>
<div class="portlet-body">
<!-- BEGIN FORM-->
<form action="" id="form_sample_1" method="post" class="form-horizontal" novalidate="novalidate" enctype="multipart/form-data" >
<div class="form-body">

 <div class="form-group">
        <label for="inputname" class="form-label">Full name</label>
        <div class="form-input">
          <input type="text" class="form-control" name="user_name" id="inputname" placeholder="Name" />
        </div>
      </div>

         <div class="form-group">
        <label for="inputusername" class="form-label">Phone no</label>
        <div class="form-input">
          <input type="number" class="form-control" name="mobile_no" id="reg_phone" placeholder="Phone no" />
        </div>
      </div>
          
       <div class="form-group">
        <label for="inputusername" class="form-label">Referred by</label>
        <div class="form-input">
            <select name="referedby" class="form-control">
            <?php
$get_customer = mysqli_query($connect,"SELECT * FROM reg_user ") or die(mysqli_error());
while($get_value = mysqli_fetch_array($get_customer)) 
{
$sno++;    
$reg_id = $get_value['reg_id'];              
$reg_name = $get_value['reg_name']; 
$regid = 'ITC'.$reg_id;
?>
            <option value="<?php echo $regid ; ?>"><?php echo $reg_name ; ?></option>

          <?php
}
?>
</select>
        </div>
      </div>
      
  

      <div class="form-group">
        <label for="inputusername" class="form-label">Email id</label>
        <div class="form-input">
          <input type="email" class="form-control" name="email" id="inputusername" placeholder="Email Id" />
        </div>
      </div>

      <div class="form-group">
        <label for="newpin" class="form-label">Password</label>
        <div class="form-input">
          <input type="number" class="form-control" name="password" id="newpin" placeholder="Password" required />
        </div>
      </div>

      <div class="form-group">
        <label for="confirmpin" class="form-label">Re-enter Password</label>
        <div class="form-input">
          <input type="number" class="form-control" name="reg_newpin" id="confirmpin" placeholder="Re-enter Password" required />
        </div>
      </div>
      <div class="remember-option mt-3">
        <div class="form-check">
          <input class="form-check-input" type="checkbox" value="" id="flexCheckDefault" />
          <label class="form-check-label" for="flexCheckDefault">I agree to all terms & condition</label>
        </div>
      </div>
  <input id="form_botcheck" name="form_botcheck" class="form-control" type="hidden" value="">
                              
      <!-- <a href="login.php" class="btn theme-btn w-100">Sign up</a> -->
      <input type="submit" name="add" value="Sign up" id="register" hidden class="btn green" />
      
<div class="form-actions">
<div class="row">
<div class="col-md-offset-3 col-md-9">
<!--<button type="submit" class="btn green" name="add" value="Create">Submit</button>-->
<button type="reset" value="Reset" class="btn grey-salsa btn-outline">Reset</button>
</div>
</div>
</div>
</form>
<!-- END FORM-->
</div>
</div>
<!-- END VALIDATION STATES-->
</div>
</div>
>
<div class="clearfix"></div>

</div>
<!-- END CONTENT BODY -->
</div>
<!-- END CONTENT -->

<!-- END QUICK SIDEBAR -->
</div>
<!-- END CONTAINER -->
<!-- BEGIN FOOTER -->
<?php include("footer.php");?>

<!-- END FOOTER -->
</div>
<!-- BEGIN QUICK NAV -->

<div class="quick-nav-overlay"></div>

<script src="assets/global/plugins/jquery.min.js" type="text/javascript"></script>
<script src="assets/global/plugins/bootstrap/js/bootstrap.min.js" type="text/javascript"></script>
<script src="assets/global/plugins/js.cookie.min.js" type="text/javascript"></script>
<script src="assets/global/plugins/jquery-slimscroll/jquery.slimscroll.min.js" type="text/javascript"></script>
<script src="assets/global/plugins/jquery.blockui.min.js" type="text/javascript"></script>
<script src="assets/global/plugins/bootstrap-switch/js/bootstrap-switch.min.js" type="text/javascript"></script>
<!-- END CORE PLUGINS -->
<!-- BEGIN PAGE LEVEL PLUGINS -->
<script src="assets/global/scripts/datatable.js" type="text/javascript"></script>
<script src="assets/global/plugins/datatables/datatables.min.js" type="text/javascript"></script>
<script src="assets/global/plugins/datatables/plugins/bootstrap/datatables.bootstrap.js" type="text/javascript"></script>
<!-- END PAGE LEVEL PLUGINS -->
<!-- BEGIN THEME GLOBAL SCRIPTS -->
<script src="assets/global/scripts/app.min.js" type="text/javascript"></script>
<!-- END THEME GLOBAL SCRIPTS -->
<!-- BEGIN PAGE LEVEL SCRIPTS -->
<script src="assets/pages/scripts/table-datatables-colreorder.min.js" type="text/javascript"></script>
<!-- END PAGE LEVEL SCRIPTS -->
<!-- BEGIN THEME LAYOUT SCRIPTS -->
<script src="assets/layouts/layout/scripts/layout.min.js" type="text/javascript"></script>
<script src="assets/layouts/layout/scripts/demo.min.js" type="text/javascript"></script>
<script src="assets/layouts/global/scripts/quick-sidebar.min.js" type="text/javascript"></script>
<script src="assets/layouts/global/scripts/quick-nav.min.js" type="text/javascript"></script>
<script src="assets/global/plugins/bootstrap-fileinput/bootstrap-fileinput.js" type="text/javascript"></script>

<!-- BEGIN PAGE LEVEL PLUGINS -->
<script src="assets/global/plugins/select2/js/select2.full.min.js" type="text/javascript"></script>
<!-- END PAGE LEVEL PLUGINS -->
<!-- BEGIN PAGE LEVEL SCRIPTS -->
<script src="assets/pages/scripts/components-select2.min.js" type="text/javascript"></script>
<script src="assets/global/plugins/bootstrap-fileinput/bootstrap-fileinput.js" type="text/javascript"></script>


<!-- repeater -->
<script src="assets/global/plugins/jquery-repeater/jquery.repeater.js" type="text/javascript"></script>
<script src="assets/pages/scripts/form-repeater.min.js" type="text/javascript"></script>
<!-- End repeater -->

<!-- END THEME LAYOUT SCRIPTS -->
<!-- Password Check -->

<!-- <script language="javascript" type="text/javascript">

function CheckFormData()

{

var product_category  = document.getElementById("product_category");

var product_name  = document.getElementById("product_name");

var product_price  = document.getElementById("product_price");

var product_description  = document.getElementById("product_description");

var image  = document.getElementById("image");

if(product_category.value == '0')

{

alert('Please Choose Category.');

product_category.focus();

product_category.style.border = 'thin solid red';

return false;

}

if(product_name.value == '')

{

alert('Please complete all fields.');

product_name.focus();

product_name.style.border = 'thin solid red';

return false;

}

if(product_price.value == '')

{

alert('Please complete all fields.');

product_price.focus();

product_price.style.border = 'thin solid red';

return false;

}

if(product_description.value == '')

{

alert('Please complete all fields.');

product_description.focus();

product_description.style.border = 'thin solid red';

return false;

}


if(image.value == '')

{

alert('Please Select Image.');

image.focus();

image.style.border = 'thin solid red';

return false;

}



return true;

}

</script> -->

</body>


</html>