How to insert console.log(res) data to database using php mysqli

i am new to node js so i am not able to insert data which is in console.log(res) of attendees details ,i need to use php mysqli to insert it into database.but index.js is in node js.thanks in advance

I’d say make a POST request with the data to your own PHP file, and in that file do the database logic.

Do not put any code dealing with databases in the web browser, in this case the Node.js client code. That will expose any credentials you may use to connect to the database.

I know php but attendee list result is in js file how to retrive it to php file to database?

You can use fetch() for making HTTP requests. MDN Documentation here.

This code should work. Just replace the URL to the URL of your own PHP file! This example assumes you want to send the data as JSON.

/* ... */

  success (res) {
    if (res) {
      if (res.errorCode > 0 || res.errorMessage !== null || res.status === false) {
        return void console.error(res)

      if (Array.isArray(res.result.attendeesList)) {
        console.log('Retrieved attendees list')

        const myUrl = ''

        fetch(myUrl, {
          method: 'post',
          headers: {
            'Content-Type': 'application/json'
          body: JSON.stringify(res.result.attendeesList)
      } else {
        console.warn('Attendees list result was not an array!', res.result)
    } else {
      console.warn('No result object in getAttendeeslist success handler')
  error (err) {
    console.error('Could not get attendees list!', err)

/* ... */

Okay, so you’re accepting FormData in your PHP file, with the res key. Therefore we need to alter the JavaScript to something like this instead:

/* ... */
const myUrl = '...';
const form = new FormData()
form.append('res', res.result.attendeesList)

fetch(myUrl, {
  method: 'post',
  body: form
}).then(() => {
  console.log('The data was uploaded!')
}).catch(err => {
  console.error('HTTP request failed', err)
/* ... */

no…in upload_attendees_list.php how to get json.stringify(res) because its showing null…i dont want to use form data…i want to get json data to upload_attendees_list.php and do database connection and store the json data…

In upload_attendees_list.php:

// Get input data as JSON
$data = json_decode(file_get_contents('php://input'), true);

echo $data;

/* Now use the $data for inserting into db */

In the JavaScript file, use the previous code sample, the one with ’Content-Type’: ’application/json’.

Also, please sanitize the php input before using it in the SQL query!

thank you for your reply.its working after using json encode

$data = json_decode(file_get_contents(‘php://input’), true);
echo $newdata;

1 Like

Yes, the ZoomMtg.getAttendeeslist() function returns an array in res.result.attendeesList. Therefore, an array is sent as JSON.

In your PHP file, you need to decode the JSON, which the code I sent does.

This gives you a PHP array of all the attendees. Then you have to loop through that array to insert each attendee one by one, if that’s what you want to do.

So your PHP file should probably look something like this:

$data = file_get_contents('php://input');
$attendeesList = json_decode($data, true);



if (is_array($attendeesList)) {
  $DataArr = array();
  foreach ($attendeesList as $key => $attendee) {
    $username = mysql_real_escape_string($attendee["userName"]);
    $DataArr[] = "('$username')";
  $sql = "INSERT INTO attendees (username) values ";
  $sql .= implode(",", $DataArr);
  echo $sql;
  $res = mysql_query($conn, $sql);
  if ($res) {
    echo "inserted";
  } else {
    echo "not";


This starts to look like StackOverflow lol.

Thank you …I will use this code and check it out…

1 Like

okay thank you i have changed code but working fine…

websdk unable to start video.Your camera has been occupied by other apps, please release the privilege and try to start when i click on video…

attendee list not visible after admitting attendee and not storing data ,again i have to refresh page to insert,how to solve this problem

After participant admit by host…it’s not storing attendence to database once I refresh page it wil store to database …I don’t want to refresh…once admit by host to participate store name to database without refresh the page

Atendee’s name not storing to dataabse once host admit to participate,through Gmail I invite each participate and url is
Automatically it won’t store name to database again I have to refresh but it’s not possible for all time…solution please

I think it all depends on where you call getAttendeeslist() and the fetch() request. Perhaps it would be easier if you could link to a GitHub page or something, so I can take a look at your code.

Can you show what your JavaScript code looks like now?

exactly same code I have used whatever u sent…but once user click on link it goes to either lounch website in browse or download zoom…once user enter his name and password it will wait for host to admin it…but the attendee name automatically not inserting it to database…

Have a look over here: getAttendeeslist() doesn't show attendees in console log only showing host name but not other attendees

Thanks for contributing to the Zoom Developer Community @daniel2! :slight_smile:

@yash.sakali, let me know if you have any additional questions.


1 Like

I can view participate after joining meeting but how do I insert participate to my database…can you help me to solve this issue?all user not joining from websdk so I don’t want to use getattendeeslist()…any other method tthanks in advance

Hey @yash.sakali,

Here is your answer:


I am not getting how to use participate webhook…can you help me to get it…I need to insert participate to my database…thanks in advance