I'm trying to finish my new personal CMS(Content Management System) and i have programmed one section which includes insert, select and delete item in one page with PHP, MySql and bootstrap Modal. obviously i have trouble with update query. The process is when i click on edit button, modal Bootstrap will show up, Then associate data will retrieve form Mysql by value attribute. after than i change them and click on submit button. The problem is here! When process complete there are errors form my $_POST['input_result']. the var_dump get NULL, and finally i have undefined index. Is there anybody to figure out this problem??? Thank you all. here is my modal Bootstrap code with PHP :
<?php
$selectForUpdate = "SELECT * FROM ring WHERE id='4'";
$resultSelectForUpdate = mysqli_query($connect_to_db, $selectForUpdate);
$first = $second = $third= '';
$first = $_POST['u_ringCode'];
$second = $_POST['u_ringWeight'];
$third = $_POST['u_ringComment'];
$updateQuery = "UPDATE ring SET ring_code='".$first."', ring_weight='".$second."', ring_comment='".$third."' WHERE id='4'";
$resultUpdateQuery = mysqli_query($connect_to_db, $updateQuery);
while ( $showUpdateRows = mysqli_fetch_assoc( $resultSelectForUpdate ) ) {
?>
<!-- Update Modal -->
<div class="modal fade bs-example-modal-sm" id="update-4" tabindex="-1" role="dialog" aria-labelledby="update-4-label" >
<div class="modal-dialog modal-sm" role="document">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">×</span></button>
<h5 class="modal-title text-center" id="update-4-label" style="color:#ddd;" >
Edit Code
</h5>
</div>
<div class="modal-body">
<div class="col-md-12 col-sm-12 col-xs-12">
<form method="post" action="<?=htmlspecialchars($_SERVER["PHP_SELF"]);?>">
<div class="form-group">
<label for="">Ring Code :</label>
<input type="text" class="form-control" id="" name="u_ringCode" placeholder="" value="<?=$showUpdateRows['ring_code']?>">
</div>
<div class="form-group">
<label for="">Ring Weight :</label>
<input type="text" class="form-control" id="" name="u_ringWeight" placeholder="" value="<?=$showUpdateRows['ring_weight']?>">
</div>
<div class="form-group">
<label for="">Comment :</label>
<input type="text" class="form-control" id="" name="u_ringComment" placeholder="" value="<?=$showUpdateRows['ring_comment']?>">
</div>
</form>
</div>
</div>
<div class="modal-footer">
<a type="button" class="btn btn-default pull-left" data-dismiss="modal">Cancel</button>
<a type="submit" class="btn btn-default pull-left" name="ringDelete" style="color:black;" href="?update=4">Submit</a>
</div>
</div>
</div>
</div>
<?php
}
?>
<?php
/*Code Start For Connnect Database*/
$connect_to_db=mysqli_connect("localhost", "root", "", "db_name" );
/*Code End For Connnect Database*/
/*Code Start For Update Modal Form*/
if (isset($_REQUEST['ringUpdate'])) {
$first = $_POST['u_ringCode'];
$second = $_POST['u_ringWeight'];
$third = $_POST['u_ringComment'];
$updateQuery = "UPDATE ring SET ring_code='".$first."', ring_weight='".$second."', ring_comment='".$third."' WHERE id='4'";
$resultUpdateQuery = mysqli_query($connect_to_db, $updateQuery);
}
/*Code End For Update Modal Form*/
$selectForUpdate = "SELECT * FROM ring WHERE id='4'";
$resultSelectForUpdate = mysqli_query($connect_to_db, $selectForUpdate);
while ( $showUpdateRows = mysqli_fetch_assoc( $resultSelectForUpdate ) ) {
?>
<!-- Update Modal -->
<div class="modal fade bs-example-modal-sm" id="update-4" tabindex="-1" role="dialog" aria-labelledby="update-4-label" >
<div class="modal-dialog modal-sm" role="document">
<div class="modal-content">
<form method="post" action="<?=htmlspecialchars($_SERVER["PHP_SELF"]);?>">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">×</span></button>
<h5 class="modal-title text-center" id="update-4-label" style="color:#ddd;" >
Edit Code
</h5>
</div>
<div class="modal-body">
<div class="col-md-12 col-sm-12 col-xs-12">
<div class="form-group">
<label for="">Ring Code :</label>
<input type="text" class="form-control" id="" name="u_ringCode" placeholder="" value="<?=$showUpdateRows['ring_code']?>">
</div>
<div class="form-group">
<label for="">Ring Weight :</label>
<input type="text" class="form-control" id="" name="u_ringWeight" placeholder="" value="<?=$showUpdateRows['ring_weight']?>">
</div>
<div class="form-group">
<label for="">Comment :</label>
<input type="text" class="form-control" id="" name="u_ringComment" placeholder="" value="<?=$showUpdateRows['ring_comment']?>">
</div>
</div>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-default pull-left" data-dismiss="modal">Cancel</button>
<input type="submit" class="btn btn-default pull-left" name="ringUpdate" style="color:black;" value="submit">
</div>
</form>
</div>
</div>
</div>
<?php
}
?>