我正在尝试从我们的数据库中获取用户数据,然后自动将这些用户传递到我的 gotowebinar。自动化代码将在 php 中完成。这是代码。我想知道为什么它不会将数据传递到 gotowebinar 页面。我能够成功检索数据。但是当我将“post”表单的代码添加到 gotowebinar 时,它不会传递数据。我希望你能帮我解决这个问题。太感谢了。
<?php
$conn = new mysqli("mywebsite.com", "myusername", "mypassword", "mydatabase");
// check connection
if ($conn->connect_error) {
trigger_error('Database connection failed: ' . $conn->connect_error, E_USER_ERROR);
}
$sql = "SELECT name, email FROM users WHERE username = 'Manny'";
$rs=$conn->query($sql);
$rs->data_seek(0);
while($row = $rs->fetch_assoc()){
?>
<form action="https://attendee.gotowebinar.com/register/11111111111" id="formGTW" method="post">
<input type="hidden" name="registrant.givenName" value="<?php echo $row['name'] ?>" />
<input type="hidden" name="registrant.surname" value="GTN" />
<input type="hidden" name="registrant.email" value="<?php echo $row['email'] ?>" />
<script type="text/javascript">
$(document).ready(function(){
$("#formGTW").submit();
});
</script>
<?php } ?>
</form>
最佳答案
您正在打印<form>
以及 while 循环内的 JavaScript,因此它将被打印多次。
$rs->data_seek(0);?>
<form action="https://attendee.gotowebinar.com/register/11111111111" id="formGTW" method="post">
<?php while($row = $rs->fetch_assoc()){
?>
<input type="hidden" name="registrant.givenName[]" value="<?php echo $row['name'] ?>" />
<input type="hidden" name="registrant.email[]" value="<?php echo $row['email'] ?>" />
<?php } ?>
<input type="hidden" name="registrant.surname" value="GTN" />
<script type="text/javascript">
$(document).ready(function(){
$("#formGTW").submit();
});
</script>
注意:我已添加 []
之后registrant.givenName
在名称字段中,以便发送所有数据(如果循环运行多次)。
关于php - 将数据从mysql传递到php到gotowebinar(通过表单post),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24238158/