在带有输入数组的while循环内使用一个提交按钮提交表单

时间:2019-02-21 22:48:08

标签: php jquery ajax

我正在尝试使用一个带有ajax请求的提交按钮来提交带有数据的多个输入。但是,响应返回一个空数组。

可能是什么问题?

jQuery

$('#setup').click(function(){
  var formData = new FormData(jQuery('#form8')[0]);
  xhr_post(formData,'./ajax/SendUsers.php','SVRMSG');
});

PHP和HTML:

echo '<form id="form8" method="POST">';

$gen = generateRandomString();
include('connection.php');

$stmt = $conn->prepare('SELECT * FROM `clients_table`,`client_education_system` WHERE id = edu_client_id  ORDER BY id ASC');
$stmt->execute();
$result = $stmt->get_result();
$num_rows = mysqli_num_rows($result);
while ($row = $result->fetch_assoc()) {
  if ($row['edu_course_D'] == 6 ){
  ?>
  ID: <input style="border:0;" type="text" disabled="disabled" name="id[]" value="<?php echo $row['id']; ?>"/>
  <br>

  Valid Until : <input style="border:0;" disabled="disabled" type="text"  name="valid[]" placeholder="validity date" value="<?php echo getLinks('24'); ?>"/>
  <br>

  Conference date: <input style="border:0;" disabled="disabled" type="text"  name="cdate[]" placeholder="conference date" value="<?php echo getContent('24'); ?>"/>
  <br>

  Serial number : <input style="border:0;" disabled="disabled" type="text" name="serial[]" placeholder="serial" value="<?php echo $row['id'].$gen; ?>"/>
  <br>

  <input   type="text"  name="" value=""/>
  <br>
  <?php
  echo '<center>';
  echo '<button id="cancelSetup" style="background:white;color:red;" type="button" name="cancelsu">Cancel</button>&nbsp;&nbsp;&nbsp;';
  echo '<button id="setup" style="background:white;color:red;" type="button" >Send</button>';
  echo '<div id="SVRMSG"></div>';
  echo "</form>";
  ?>

sendusers.php文件

<?php
require_once('..\inc\backend-func.php');

if( $_SERVER['REQUEST_METHOD']  == 'POST'){
  print_r($_POST);
}
?>

0 个答案:

没有答案