Mini Shell

Direktori : /home2/aravindar/public_html/admin/
Upload File :
Current File : /home2/aravindar/public_html/admin/useredit_model.php

<?php 
include("config.php");
$conn = dbconnect();
 
$id = $_GET['id'];

$today= date('Y-m-d');
?>
<h3>Edit User - <?php echo $id; ?></h3>
<?php
$content_query = "SELECT * FROM tb1_admin WHERE admin_id = '$id'";
$content_res = mysqli_query($conn, $content_query);
$content_row = mysqli_fetch_object($content_res);
$user_name=$content_row->name;
$username=$content_row->user_name;
$status=$content_row->status;
$user_id=$content_row->admin_id;
$user_dob=$content_row->dob;
$user_gender=$content_row->gender;
$user_position=$content_row->position;
$user_phone=$content_row->phone;
$user_password=$content_row->password;
?>
<form class="edit-form" id="editForm" enctype="multipart/form-data">
<div class="col-md-12">
    <div class="card-block">
            <input type="hidden" name="type" value="update"> 
            <input type="hidden" name="user_id" value="<?php echo $user_id ?>">
            <div class="form-group row">
                <label class="col-md-3 col-form-label">Name </label>
                <div class="col-md-9">
                   <input type="text" class="form-control" id="user_name" name="user_name" value="<?php echo $user_name; ?>"> </div>
                </div>
                <div class="form-group row">
                <label class="col-md-3 col-form-label">Mobile </label>
                <div class="col-md-9">
                   <input type="text" class="form-control" id="user_phone" name="user_phone" value="<?php echo $user_phone; ?>"> </div> 
                </div>
                <div class="form-group row">
                <label class="col-md-3 col-form-label">Gender </label>
                <div class="col-md-9">
                   <select type="text" class="form-control" id="user_gender" name="user_gender">
                    <option value="Male" <?php if($user_gender == 'Male') echo "selected";  ?> >Male</option>
                    <option value="Female" <?php if($user_gender == 'Female') echo "selected" ?>>Female</option>
                  </select></div>
                </div>
                <div class="form-group row">
                <label class="col-md-3 col-form-label">Position </label>
                <div class="col-md-9">
                   <select type="text" class="form-control" id="user_position" name="user_position" <?php if($position == 2 || $position == 3) echo "disabled"  ?>>
                    <option value="1" <?php if($user_position == 1) echo "selected"  ?> >Main Admin</option>
                    <option value="2" <?php if($user_position == 2) echo "selected"  ?>>HR Team</option>
                    <option value="3" <?php if($user_position == 3) echo "selected"  ?>>Marketing</option>
                  </select> </div>
                </div>
                <div class="form-group row">
                <label class="col-md-3 col-form-label">User Name </label>
                <div class="col-md-9">
                    <input type="text" class="form-control" id="username"  name="username" value="<?php echo $username; ?>">  </div>
                </div>
               <div class="form-group row">
                <label class="col-md-3 col-form-label">Password</label>
                <div class="col-md-9">
                    <input type="password" class="form-control" id="user_password"  name="user_password" value="<?php echo $user_password; ?>"> </div>
                </div>
            <div class="form-group row">
                <label class="col-md-3 col-form-label">Status </label>
                <div class="col-md-9">
                    <select class="form-control news_status" id="status" name="status" >
                    <option value="1" <?php if($status == 1) echo 'selected'; ?>>Active</option>
                    <option  value="0" <?php if($status == 0) echo 'selected'; ?>>Inactive</option>
                  </select>
                </div>
            </div>
            
           
        
    </div>
</div>
<div class="col-md-12 text-center">
    <button type="submit" class="btn btn-success text-bold" id="sub-btn" style="width: -webkit-fill-available;">Submit</button>
</div>
</form>
 <!-- jquery file upload js -->
    <script src="assets/pages/jquery.filer/js/jquery.filer.min.js"></script>
    <script src="assets/pages/filer/custom-filer.js" type="text/javascript"></script>
    <script src="assets/pages/filer/jquery.fileuploads.init.js" type="text/javascript"></script>
    <script src="assets/validation/jquery-validation/jquery.validate.min.js"></script>
    <script src="assets/css/validation/form-validation.js"></script>
    <script type="text/javascript">
  // initialize validate plugin on the form
    $("#editForm").validate({
        errorPlacement: function(error, element) {
            var ele = $(element),
                err = $(error),
                msg = err.text();
            if (msg != null && msg !== "") {
                ele.tooltipster('content', msg);
                ele.tooltipster('open'); //open only if the error message is not blank. By default jquery-validate will return a label with no actual text in it so we have to check the innerHTML.
            }
        },
        unhighlight: function(element, errorClass, validClass) {
            $(element).removeClass(errorClass).addClass(validClass).tooltipster('close');
        },
       
        submitHandler: function(form) { // for demo
         var form = $('#editForm')[0];
        var formData = new FormData(form);
        event.preventDefault();
         $("#sub-btn").attr("disabled", true);
            $.ajax({
            type: 'POST',
            url: 'ajax/user_action',
            processData: false,
            contentType: false,
            dataType: "json",
            data: formData,
            success: function (data) {
              if(data=='done'){
                swal({
                  title: 'Updated Successfully!',
                        text: "The User has been successfully Updated",
                        icon: 'success',
                        confirmButtonColor: '#3f51b5',
                        closeOnEsc: false,
                        closeOnClickOutside: false,
                        buttons: {
                        confirm: {
                          text: "Okay",
                          value: true,
                          visible: true,
                          className: "btn btn-primary",
                          closeModal: true
                        }
                      }    
                }).then((value) => {
                if(value==true){
                  location.reload();
                }
              });
               } 
            },
            error: function (data) {
               swal({
                  title: 'Internal Sever Error!',
                        text: "Try again",
                        icon: 'warning',
                        closeOnEsc: false,
                        closeOnClickOutside: false,   
                })
            },
        });
        }
    });
</script>

Zerion Mini Shell 1.0