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

将数据从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>

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.