<?php

if($_SESSION["type"] != 1){
	echo "No permission to access"; die();
	}

?>
<div class="row">
    <div class="col-lg-12" style="margin-top:-41px;margin-bottom:-13px;">
        <h1 class="page-header" style="font-size:19px; color:#09F;"><i class="fa fa-user fa-fw"></i>&nbsp;Addnew User</h1>
    </div>
    <!-- /.col-lg-12 -->
</div>
<?php       
    if (isset($_POST['btsave'])) {
        $full_name = $_POST['fullname'];
        $username  = $_POST['username'];
        $password  = md5($_POST['password']);
        $desc      = $_POST['desc'];
		$utype     = $_POST['type'];
		$email     = $_POST['email'];
		$date = date('Y-m-d', time());
        mysqli_query($conn,"SET NAMES utf8");
        mysqli_query($conn,"insert into tbl_user values('','$username','$full_name','$password','$date','$desc',$utype,'$email')") or die(mysql_error());
        
        ?>
        	<script type="text/javascript">
              window.location.href="?page=user";
            </script>
       <?php 
    }   
?> 
<div class="row">
    <div class="col-lg-12">
        <div class="panel panel-default" style="width:100%;">
            <div class="panel-body">
                <div class="row">
                    <form method="post" enctype="multipart/form-data">
                        <div class="col-lg-6">
                            <div class="form-group">
                                <label style="color:#3a3a3a;">Full Name</label>
                                <input class="form-control" placeholder="Full Name" name="fullname" required />
                            </div>
                            <div class="form-group">
                                <label style="color:#3a3a3a;"v>User Name</label>
                                <input class="form-control" placeholder="User Name" name="username" required/>
                            </div>
                            <div class="form-group">
                                <label style="color:#3a3a3a;"v>Email</label>
                                <input type="email" class="form-control" placeholder="Email" name="email" required/>
                            </div>
                            <div class="form-group" style="padding-bottom:10px;">
                                <label>Type &nbsp;&nbsp; 1 : Administrator&nbsp;&nbsp; 2 : Normal User</label>
                                <input class="form-control" placeholder="User Type" name="type" required />
                            </div>
                            <div class="form-group">
                                <label style="color:#3a3a3a;">Password</label>
                                <input  type="password" class="form-control" placeholder="Password" name="password" required/>
                            </div>
                            <div class="form-group" style="margin-bottom:0px;">
                                <label style="color:#3a3a3a;">Description</label>
                                <textarea class="form-control" rows="3" name="desc" placeholder="Description"></textarea>
                            </div>
                            <div class="form-group">
                                <label></label><br/>
                                <input type="submit" name="btsave" class="btn btn-success" value="&nbsp;Save&nbsp;" title="Save"/>
                                 
                            </div> 
                        </div>
                           
                    </form>
                </div>
            </div>
       </div>
    </div>
</div>

