ok
Direktori : /home2/selectio/www/lilyexpresslive/software/admin/ |
Current File : /home2/selectio/www/lilyexpresslive/software/admin/system-user-add.php |
<?php require_once('header.php'); ?> <?php if(isset($_POST['form1'])) { // var_dump($_POST); $valid = 1; if(empty($_POST['full_name'])) { $valid = 0; $error_message .= 'Name can not be empty<br>'; } if(empty($_POST['phone'])) { $valid = 0; $error_message .= 'Phone No can not be empty<br>'; } if(empty($_POST['email'])) { $valid = 0; $error_message .= 'Email Address can not be empty<br>'; } if(empty($_POST['address'])) { $valid = 0; $error_message .= 'Address can not be empty<br>'; } if(empty($_POST['status'])) { $valid = 0; $error_message .= 'Status Code can not be empty<br>'; } if(empty($_POST['password'])) { $valid = 0; $error_message .= 'Password can not be empty<br>'; } $code=$_POST['email']; $statement = $pdo->prepare("SELECT * FROM tbl_system_user where email='$code'"); $statement->execute(); $result = $statement->fetchAll(PDO::FETCH_ASSOC); if($result) { $valid=0; $error_message .= 'Email No Alreay Exist<br>'; } if($valid==1) { $statement = $pdo->prepare("INSERT INTO tbl_system_user (full_name,phone,address,status,password,role,role_type,email,role_ids) VALUES (?,?,?,?,?,?,?,?,?)"); $statement->execute(array($_POST['full_name'],$_POST['phone'],$_POST['address'],$_POST['status'],$_POST['password'],'Employee',2,$_POST['email'],$_POST['role_name'])); $success_message = 'System User is added successfully!'; unset($_POST['full_name']); unset($_POST['email']); unset($_POST['gst_no']); unset($_POST['phone']); unset($_POST['address']); unset($_POST['status']); unset($_POST['location']); unset($_POST['password']); unset($_POST['short_location']); unset($_POST['role_name']); } } ?> <section class="content-header" style="background-color: white;"> <div class="row"> <div class="col-md-6" style="text-align: left;"> <a href="system-users.php" class="btn btn-primary btn-sm">View All</a> <h4><i class="fa fa-user-plus"></i> System Users</h4> </div> </div> </section> <section class="content"> <div class="row"> <div class="col-md-12"> <?php if($error_message): ?> <div class="callout callout-danger"> <p> <?php echo $error_message; ?> </p> </div> <?php endif; ?> <?php if($success_message): ?> <div class="callout callout-success"> <p><?php echo $success_message; ?></p> </div> <?php endif; ?> <form class="form-horizontal" action="" method="post" enctype="multipart/form-data"> <div > <div class="box-body"> <div class="form-group"> <label for="" class="col-sm-2 control-label">Name <span>*</span></label> <div class="col-sm-6"> <input type="text" autocomplete="off" class="form-control" name="full_name" value="<?php if(isset($_POST['full_name'])){echo $_POST['full_name'];} ?>" required> </div> </div> <div class="form-group"> <label for="" class="col-sm-2 control-label">Phone Number <span>*</span></label> <div class="col-sm-6"> <input type="number" autocomplete="off" class="form-control" name="phone" value="<?php if(isset($_POST['phone'])){echo $_POST['phone'];} ?>" required> </div> </div> <div class="form-group"> <label for="" class="col-sm-2 control-label">Email <span>*</span>(Unique its an Username)</label> <div class="col-sm-6"> <input type="email" autocomplete="off" class="form-control" name="email" value="<?php if(isset($_POST['email'])){echo $_POST['email'];} ?>" required> </div> </div> <div class="form-group"> <label for="" class="col-sm-2 control-label">Password <span>*</span></label> <div class="col-sm-6"> <input type="text" autocomplete="off" class="form-control" name="password" value="<?php if(isset($_POST['password'])){echo $_POST['password'];} ?>" required> </div> </div> <div class="form-group"> <label for="" class="col-sm-2 control-label">Address <span>*</span></label> <div class="col-sm-6"> <input type="text" autocomplete="off" class="form-control" name="address" value="<?php if(isset($_POST['address'])){echo $_POST['address'];} ?>" required> </div> </div> <div class="form-group"> <label for="" class="col-sm-2 control-label">Role Name<span>*</span></label> <div class="col-sm-6"> <select class="form-control select2" name="role_name" id="role_name"> <?php $statement = $pdo->prepare("SELECT * FROM tbl_role WHERE status=1 ORDER BY id ASC"); $statement->execute(); $result = $statement->fetchAll(PDO::FETCH_ASSOC); foreach ($result as $row) { ?> <option value="<?php echo $row['id']; ?>"><?php echo $row['role_name']; ?></option> <?php } ?> </select> </div> </div> <div class="form-group"> <label for="" class="col-sm-2 control-label">Status <span>*</span></label> <div class="col-sm-6"> <select class="form-control select2" name="status" id="status"> <!--<option >Select Client Status</option>--> <option value="Active" <?php if(isset($_POST['status'])) {if($_POST['status']=='Active'){echo "selected";}} ?>>Active</option> <option value="Inactive" <?php if(isset($_POST['status'])) {if($_POST['status']=='Inactive'){echo "selected";}} ?>>Inactive</option> </select> </div> </div> <div class="form-group"> <label for="" class="col-sm-2 control-label"></label> <div class="col-sm-6"> <button type="submit" class="btn btn-success pull-left" name="form1">Submit</button> </div> </div> </div> </div> </form> </div> </div> </section> <?php require_once('footer.php'); ?>