function print_form($site_id = '', $page_type = '', $site_template = '', $form_id = '', $fields_num = 5)
{
    echo '<form class="jotform-form" action="http://submit.jotform.co/submit/' . $form_id . '/" method="post" name="form_' . $form_id . '" id="' . $form_id . '" accept-charset="utf-8">';
    echo '<input type="hidden" name="formID" value="' . $form_id . '" />';
    form_fields($fields_num);
    echo '<input type="hidden" id="simple_spc" name="simple_spc" value="' . $form_id . '" /><script type="text/javascript">document.getElementById("si" + "mple" + "_spc").value = "' . $form_id . '-' . $form_id . '";</script>';
    echo '</form>';
}
function module_try_buy(&$data)
{
    list($data['page']) = explode('/', $data['__key']);
    $data['fields'] = form_fields();
    if ($data['view'] == 'process') {
        $valid = validate_form($data['user']);
        if ($valid) {
            $sql = "INSERT INTO `try_buy_user` ";
            $sql .= "(";
            foreach ($data['fields'] as $k => $v) {
                $sql .= $k . ",";
            }
            // Lop off the last ','
            $sql = substr($sql, 0, -1);
            $sql .= ") VALUES (";
            // (val1,val2,val3,)
            foreach ($data['fields'] as $k => $v) {
                if ($k == 'timestamp') {
                    $sql .= time() . ",";
                    continue;
                } elseif ($k == 'status') {
                    $sql .= STATUS_LIVE . ",";
                    continue;
                } else {
                    $sql .= "'" . addslashes($data['user'][$k]) . "',";
                }
            }
            // Lop off the last ','
            $sql = substr($sql, 0, -1);
            $sql .= ");";
            $result = db_exec($sql);
            //          $db_result = go_db ( $data );
            // go_db ( $data );
        }
        $json_send = array();
        $json_send['user'] = $data['user'];
        header('Content-Type: application/json');
        echo json_encode($json_send, true);
        exit;
        //        }
    }
    // elseif ( $data['view'] == 'process' )
    //   {
    //     $json_send = array () ;
    //     $json_send['user'] = $data['user'];
    //     header ( 'Content-Type: application/json' );
    //     echo json_encode ( $json_send, true );
    //     exit;
    //   }
    if ($data['__key'] == 'terms') {
        $data['terms'] = file_get_contents(SITE_ROOT . 'data/' . $data['__this'] . '/terms.html');
    }
    core_set_template('try_buy');
    core_head_add('jquery');
    core_set_title('ODA Try Buy Promotion');
}
Beispiel #3
0
/**
 * 获得表单【后台可添加表单】
 *
 * @access  public
 * @param   $form_id:表单标示
 * @return  string
 */
function get_form($form_id = '')
{
    if (empty($form_id)) {
        $sql = "select form_id from " . DB_PRE . "category where id=" . intval($GLOBALS['id']);
        $rel = $GLOBALS['mysql']->fetch_asc($sql);
        return empty($rel[0]['form_id']) ? '' : form_fields($rel[0]['form_id'], CMS_SELF);
    } else {
        return form_fields($form_id, CMS_SELF);
    }
}