<?PHP

ob_start();

session_start();

include 'connect.php';

if(isset($_SESSION['adminemail']))

{

$user=$_SESSION['adminemail'];



$gtp=mysqli_query($conn,"select * from admin where username='$user'");

$gtp1=mysqli_fetch_assoc($gtp);



include 'top.php';

?>






<div id="page-wrapper" >
          <div id="page-inner">
<div class="main-content">

				<div class="main-content-inner">

					<div class="breadcrumbs ace-save-state" id="breadcrumbs">

						<ul class="breadcrumb">

							<li>

								<i class="ace-icon fa fa-home home-icon"></i>

								<a href="#">Home</a>

							</li>

							<li class="active">Users</li>

						</ul><!-- /.breadcrumb -->

					</div>



					<div class="page-content">

			



						<div class="page-header">

                        

<?php



$aca=mysqli_query($conn,"select * from financial where user='$user' order by ID desc");

$aca1=mysqli_fetch_assoc($aca);



$financial=$aca1['financial'];



?>

                        

                        <table style="width:100%;">

                        

                        <tr><td style="width:50%;">

                        

							<h1>

								User Register

							</h1>

                            

                            </td>

                            

                            <td style="width:50%; text-align:right; padding-right:15px; font-size:15px;">

                            

                            <i class="fa fa-calendar"></i>&nbsp; <?php echo $financial; ?>

                            

                            </td></tr></table>

                            

						</div> <!-- /.page-header -->



						<div class="row">

							<div class="col-xs-12">

                            

								<!-- PAGE CONTENT BEGINS -->

                                

<script src="assets/js/jquery.js"></script>

<script>

	

jQuery(function($){

		   

	// simple jQuery validation script

	$('#course').submit(function(){

		

		var valid = true;

		var errormsg = 'This field is required!';

		var errorcn = 'error';

		

		$('.' + errorcn, this).remove();			

		

		$('#required', this).each(function(){

			var parent = $(this).parent();

			if( $(this).val() == '' ){

				var msg = $(this).attr('title');

				msg = (msg != '') ? msg : errormsg;

				$('<span style="font-size:13px;color:#FF0000; padding-left:3px;" class="'+ errorcn +'">'+ msg +'</span>')

					.appendTo(parent)

					.fadeIn('fast')

					.click(function(){ $(this).remove(); });

				valid = false;

			};

		});

		

		return valid;

	});

	

});	



</script>



<?php        



if (isset($_POST['submit'])) { 



$name=$_POST['name'];

$email = $_POST['email'];

$type = $_POST['type'];

$username = $_POST['username'];



$verify=mysqli_query($conn,"select * from admin where username='$username'");

$verify1=mysqli_num_rows($verify);



if($verify1>0)

{

die('<script type="text/javascript">alert("Username already registered!");</script><META HTTP-EQUIV = "Refresh" Content = "1; URL =register.php">');

}



if($_POST['pass']!= $_POST['pass2'])

{

die('<script type="text/javascript">alert("Your Password Do Not Match!");</script><META HTTP-EQUIV = "Refresh" Content = "1; URL =register.php">');

}



	  $password=$_POST['pass'];

      $password=strip_tags($password);

      $password=trim($password);

      $password=md5($password);



if($password && $username)

{ 



 	$insert= "INSERT INTO admin(name,email,password,username,type) VALUES('$name','$email','$password','$username','$type')";

 	$add_member = mysqli_query($conn,$insert) or die(mysqli_error($conn));



}



else

{

echo '<script type="text/javascript">alert("Field Missing");</script><META HTTP-EQUIV = "Refresh" Content = "1; URL =register.php">';

}



if($add_member)

{

 header("location:register.php?s=1");

}



}



else 

{



		if(isset($_GET['s'])) 

		{

		 $status=$_GET['s'];

			 if($status=='1')

			 {

			   echo'<div class="alert alert-success alert-dismissable">

					<button type="button" class="close" data-dismiss="alert" aria-hidden="true">&times;</button>

					<span style="text-align:left;">Registered Successfully.</span>

					</div><br />';

			}

		}



echo'<form id="course" action="register.php" method="post">



<table width="70%" style="margin:auto; line-height:35px;">



<tr><td>Name <span class="red">  </span></td><td id="page"></td><td><input  class="form-control" style="width: 30ch; margin-bottom:10px" autocomplete="off" type="text" id="required" title="*" name="name" /></td></tr>



<tr><td>E-Mail Id </td><td id="page"></td><td><input  class="form-control" style="width: 30ch; margin-bottom:10px" autocomplete="off" type="text" name="email" /></td></tr>



<tr><td>User Name <span class="red">  </span></td><td id="page"></td><td><input  class="form-control" style="width: 30ch; margin-bottom:10px" autocomplete="off" type="text" name="username" id="required" title="*" /></td></tr>



<tr><td>Password <span class="red">  </span></td><td id="page"></td><td><input  class="form-control" style="width: 30ch; margin-bottom:10px" type="password" name="pass" id="required" title="*" style="width:220px; height:30px;" /></td></tr>



<tr><td>Confirm Password <span class="red">  </span></td><td id="page"></td><td><input  class="form-control" style="width: 30ch; margin-bottom:10px" type="password" name="pass2" id="required" title="*" style="width:220px; height:30px;" /></td></tr>



<tr><td>Type <span class="red">  </span></td><td id="page"></td><td><select  class="form-control" style="width: 30ch; margin-bottom:10px" name="type" id="required" title="*" style="width:220px;">

<option value="">Select Type</option><option value="admin">Admin</option><option value="staff">Staff</option></select></td></tr>



<tr><td></td><td></td><td align="left"><button type="submit" class="btn btn btn-primary" value="Login" name="submit">Register</button></td></tr>



</table>



</form>';



}



?>



								<!-- PAGE CONTENT ENDS -->

							</div><!-- /.col -->

						</div><!-- /.row -->

					



</div><!-- /.page-content -->

				</div>

			</div><!-- /.main-content -->
			</div><!-- /.main-content -->
			</div><!-- /.main-content -->





<?php

include 'bottom.php';

}

else

{



 header("location:login.php");

}

ob_flush();

?>