doulang1945 2014-06-16 07:00
浏览 40
已采纳

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

I'm trying to fetch user data from our database, then pass these users to my gotowebinar automatically. The automated code will be done in php. Here's the code. I am wondering why it won't pass the data to the gotowebinar page. I was able to retrieve the data successfully. But when I added my code for the form "post" to gotowebinar, it won't pass the data. I hope you could help me with this. Thank you so much.

<?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>
  • 写回答

1条回答 默认 最新

  • douhan9467 2014-06-16 07:07
    关注

    You are printing <form> as well as the javascript inside while loop so it will be printed multiple times.

    $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>
    

    Note: I have added [] after registrant.givenName in name field so that all the data(if the loop runs more than once) will be sent.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥100 set_link_state
  • ¥15 虚幻5 UE美术毛发渲染
  • ¥15 CVRP 图论 物流运输优化
  • ¥15 Tableau online 嵌入ppt失败
  • ¥100 支付宝网页转账系统不识别账号
  • ¥15 基于单片机的靶位控制系统
  • ¥15 真我手机蓝牙传输进度消息被关闭了,怎么打开?(关键词-消息通知)
  • ¥15 装 pytorch 的时候出了好多问题,遇到这种情况怎么处理?
  • ¥20 IOS游览器某宝手机网页版自动立即购买JavaScript脚本
  • ¥15 手机接入宽带网线,如何释放宽带全部速度