Modal中的文本框显示文本,但$ _POST [' inputbox']未获得文本框的值

时间:2017-03-29 15:48:55

标签: php jquery twitter-bootstrap

模态通过jquery获取值。和模态中的文本框显示文本。但是当我尝试编辑数据并保存时,文本框中的值不会是$ _POST。  莫代尔:

<button type="submit" class="btn btn-success"  data-toggle="modal"  data-cphone='.$row['country_phon'].' data-cname='.$row['country_name'].' >Update</button>';
<div id="myModal" class="modal fade" tabindex="-1" role="dialog">
<div class="modal-dialog">

 <!-- Modal content-->
  <div class="modal-content">
        <div class="modal-header">
            <button type="button" class="close" data-dismiss="modal">&times;</button>
             <h4 class="modal-title">Update Country</h4>
        </div>
<form action="" method="post">
            <div class="modal-body">
                 <input type="text" id="cn"  name="pcountry">
  </div>
            <div class="modal-body">
                 <input type="text" id="cph" name="pphone">
            </div>
            <div class="modal-footer">
                <button type="submit" class="btn btn-primary updt" name="updatecountry" >Save</button>

Jquery Code:将数据发送到modal

中的Textbox
<script>
  $(document).ready(function(){
  $(".btn").click(function(){     
  var cphone =$(this).data('cphone');   
  var cname =  $(this).data('cname');
  $("#cph").val(cphone);
  $("#cn").val(cname);
  $("#myModal").modal('show');   
 });
 });</script>

PHP COde:$ country1,$ phone1不是textbox的getign值

<?php 
if(isset($_POST['updatecountry']))
 { $country1 = $_POST['pcountry'];
    $phone1 =   $_POST['pphone'];

 mysqli_query($conn,"update country set country_name='$country1' , country_phon='$phone1' where country_id=18");
 mysqli_close($conn);   
 }?>

0 个答案:

没有答案