在PHP的while循环中提交包含post数据的表单 $i=1; 而($getPending=$getPendin->fetch(PDO::fetch_ASSOC)){ ?>
如我所见,您看起来不需要表单中的用户交互,如果需要, 您可以仅在PHP上直接执行请求,例如使用curl,如下所示:在PHP的while循环中提交包含post数据的表单 $i=1; 而($getPending=$getPendin->fetch(PDO::fetch_ASSOC)){ ?>,php,Php,如我所见,您看起来不需要表单中的用户交互,如果需要, 您可以仅在PHP上直接执行请求,例如使用curl,如下所示: $i = 1; while ($getPending = $getPendin->fetch(PDO::FETCH_ASSOC)) { ?> <form action="https://www.dummy.com/abc/dummyurl" method="post" name="payuForm"
$i = 1;
while ($getPending = $getPendin->fetch(PDO::FETCH_ASSOC)) {
?>
<form action="https://www.dummy.com/abc/dummyurl" method="post" name="payuForm" id="payu<?php echo $i?>">
<input type="hidden" class="position-absolute" name="msg" value="<?php echo $str; ?>"/>
</form>
<script type="text/javascript">
document.getElementById('<?php echo 'payu'.$i?>').submit(); // SUBMIT FORM
</script>
<?php } ?>
<?php
$ch = curl_init();
while ($getPending = $getPendin->fetch(PDO::FETCH_ASSOC)) {
curl_setopt($ch, CURLOPT_URL, "https://www.dummy.com/abc/dummyurl");
curl_setopt($ch, CURLOPT_POST, 1); // method "post"
curl_setopt($ch, CURLOPT_POSTFIELDS,
http_build_query(array('msg' => $str))); // Your data in the array()
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$server_output = curl_exec($ch);
if ($server_output == "OK") {
// Here you update the result in the database in response
} else {
}
}
curl_close ($ch);
<?php while ($getPending = $getPendin->fetch(PDO::FETCH_ASSOC)) { ?>
$.post(
"https://www.dummy.com/abc/dummyurl",
{ msg: <?= $str ?> }, // Your data here
function(data) {
// success
// Here you make a second json request to update the result in the database
// A php that you have created to add the data into your base
$.post(
"https://your-own-url.com/for-update-data-by-the-result.php",
{ yourfield1: data.valuefield1 },
function() {
// success, handle it if you nee
}
);
}
);
<?php } ?>