
 <div class="container-fluid">
   <div class="row">
      <div class="col-sm-12 col-lg-12">
         <div class="iq-card">
            <div class="iq-card-header d-flex justify-content-between">
               <div class="iq-header-title">
                  <h4 class="card-title">Add Game Data</h4>
               </div>
               <span class="table-add float-right mb-3 mr-2">
                  <a href="<?php echo base_url(); ?>game/" class="btn btn-default pull-right"><i class="fa fa-arrow-left" aria-hidden="true"></i> Back</a>&emsp;
               </span>
            </div>
            <div class="iq-card-body">
               <div class="alert alert-success Add" style="display: none;">
                    <strong>Successfully Added Your Data!</strong>
                </div>
                <div class="alert alert-danger Adderror" style="display: none;">
                    <strong>Duplicate Entry!</strong>
                </div>
                <form role="form" method="post" id="addfrm">
                <div class="row">
                    
                    <div class="col-lg-12 col-md-12 col-sm-12 col-xs-12">
                        <div class="form-group">
                            <label>Game Name</label>
                            <input type="text" name="name" id="name" class="form-control" required="" placeholder="Enter Game Name"><br>
                        </div>
                    </div>
                    <div class="col-lg-12 col-md-12 col-sm-12 col-xs-12">
                        <div class="form-group">
                            <label>Image </label>
                            <input type="file" name="image" id="image" class="form-control" required=""><br>
                        </div>
                    </div>
                    <div class="col-lg-12 col-md-12 col-sm-12 col-xs-12" align="right">
                        <div class="form-group">
                            <button type="reset" class="btn btn-default"><i class="fa fa-repeat" aria-hidden="true"></i> Reset</button>
                            <button type="submit" class="btn btn-primary addbtn"><i class="fa fa-floppy-o" aria-hidden="true"></i> Save</button>
                            <button class="btn btn-primary addload buttonload" style="display: none;"><i class="fa fa-spinner fa-spin" style=" margin-left: -12px; margin-right: 8px;"></i>Please Wait</button>
                        </div>
                    </div>
                    
                </div>
                </form>
            </div>
         </div>
      </div>
   </div>
</div>
<script>
// just for the demos, avoids form submit
jQuery.validator.setDefaults({
success: "valid"
});
$("#addfrm").validate({
rules: {
d_code: {
required: true
}
}
});
</script>
<script>
$(document).ready(function(e) {
$("#addfrm").on('submit', function(e) {
e.preventDefault();
var formStatus = $('#addfrm').validate().form();
if (true == formStatus) {
$.ajax({
type: 'POST',
url: '<?php echo base_url(); ?>game/save',
data: new FormData(this),
contentType: false,
cache: false,
processData: false,
beforeSend: function() {
$('.addbtn').hide();
$('.addload').show();
},
success: function(msg) {
if(msg=='Success')
{
$(".Add").show();
$('.Add').delay(3000).hide(200);
$('.addbtn').show();
$('.addload').hide();
setInterval(function() {
location.reload();
}, 3000);
}
else
{
$(".Adderror").show();
$('.Adderror').delay(3000).hide(200);
$('.addbtn').show();
$('.addload').hide();

}
}
});
}
});
});
</script>