i want use modal form populate current table won't work. need help, might have missed here. thanks!
here's code button:
<button type="button" class="btn btn-primary" data-toggle="modal" data-target="#addmodal" href="add_dept.php">+ add department</button>
here's code in bottom of file show modal content:
<div class="modal fade" id="addmodal" tabindex="-1" role="dialog" aria-labelledby="mymodallabel"> <div class="modal-dialog" role="document"> <div class="modal-content"> </div> </div>
here's code add_dept.php:
<?php include("../includes/config.php"); $reqerr = ""; if($_server['request_method'] == "post") { if(!empty($_post['dept_name']) && !empty($_post['dept_code'])) { $dept_name = $_post['dept_name']; $dept_code = $_post['dept_code']; $query_adddept = "insert department(dept_name,dept_code) values('$dept_name','$dept_code')"; if(mysqli_query($con,$query_adddept)) { $reqerr = '<div class="alert alert-success" id="myalert"> <a href="" class="close"> <i class="fa fa-times"></i></a> <i class="fa fa-check-circle"></i> department added</div>'; mysqli_close($con); } else { $reqerr = '<div class="alert alert-danger" id="myalert"> <a href="" class="close"> <i class="fa fa-times"></i></a> <i class="fa fa-exclamation-circle"></i> failed add department</div>'; } } } ?> <?php echo $reqerr; ?> <div class="modal-header"> <button type="button" class="close" data-dismiss="modal">×</button> <h4 class="modal-title">add department</h4> </div> <div class="modal-body"> <form method="post" class="form" id="add-department" role="form"> <div class="form-group"> <input type="text" class="form-control" id="dept_name" name="dept_name" placeholder="department name" /> <span class="help-block"></span> </div> <div class="form-group"> <input type="text" class="form-control" id="dept_code" name="dept_code" placeholder="department code" /> <span class="help-block"></span> </div> <div class="modal-footer"> <button type="button" class="btn btn-default" data-dismiss="modal">close</button> <input type="submit" id="submit_btn" class="btn btn-primary" /> </div> </form> </div>
<button type="button" class="btn btn-primary" data-toggle="modal" data-target="#addmodal" href="add_dept.php">+ add department</button>
delete href=""
<div class="modal fade" id="addmodal" tabindex="-1" role="dialog" aria-labelledby="mymodallabel"> <div class="modal-dialog" role="document"> <div class="modal-content"> <?php require_once('add_dept.php'); ?> </div> </div> </div>
add last - close div
Comments
Post a Comment