php - 将数据从mysql传递到php到gotowebinar(通过表单post)

标签 php mysql forms post

我正在尝试从我们的数据库中获取用户数据,然后自动将这些用户传递到我的 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/

相关文章:

php - fgets()超时

c# - 相对于菜单调整表单内容的问题

html - 如何将 html 表单转换为 Django 表单并保留样式?

php - 如何将 fetch(PDO::FETCH_ASSOC) 中的单个值或整个数组存储在变量中?

php - 防止在 PHP 中的高级 MySQL 存储过程语句中注入(inject)

MySQL:如果在第二个表中找到匹配的 id 并添加缺少的内容,如何在第一个表中获取 "overwrite"数据

mysql - 从一个字符串中获取多个子字符串

python - django 多选浏览器按钮,形式类似于 html

php - 使用 jquery 创建 php session

mysql - 在 mysql CL 中使用变量