You are here

function _webform_save_submission in Webform 5

1 call to _webform_save_submission()
webform_client_form_submit in ./webform.module

File

./webform.module, line 1760

Code

function _webform_save_submission($node, $submitted) {
  global $user;
  $sid = db_next_id('{webform_submissions}_sid');
  db_query("INSERT INTO {webform_submissions} (nid, sid, uid, submitted, remote_addr) " . " VALUES (%d, %d, %d, %d, '%s')", $node->nid, $sid, $user->uid, time(), $_SERVER['REMOTE_ADDR']);
  foreach ($submitted as $cid => $value) {
    if (is_array($value)) {
      $delta = 0;
      foreach ($value as $k => $v) {
        db_query("INSERT INTO {webform_submitted_data} (nid, sid, cid, no, data) " . "VALUES (%d, %d, %d, %d, '%s')", $node->nid, $sid, $cid, $delta, $v);
        $delta++;
      }
    }
    else {
      db_query("INSERT INTO {webform_submitted_data} (nid, sid, cid, no, data) " . "VALUES (%d, %d, %d, %d, '%s')", $node->nid, $sid, $cid, 0, $value);
    }
  }
  return $sid;
}