/var/www/hkosl.com/sinomax/survey/webadmin/survey_form_modify.php


1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
<?php
    
require_once('check_login.php');

    
/*$message = "";

    if (empty($_POST["form_xml"]) || empty($_POST["form_html"])) {
        $message .= "Cannot get form data. Please try again.";
    }

    if (!empty($message)) {
        echo $message;
        exit;
    }*/

    
if (empty($_POST["form_xml"]) || empty($_POST["form_html"])) {
        exit;
    }

    
$form_xml str_replace('selected="true"'""$_POST["form_xml"]);

    
$result fn_parse_form_data($form_xml);

    
/*var_dump($result);
    exit;*/

    //deleted old question
    
$sql        "update question set deleted = ? where campaign_id = ?";
    
$parameters = array(1, (int)$_POST["campaign_id"]);
    
bind_pdo($sql$parameters);

    
$sort 1;
    foreach (
$result as $question) {
        
$required $question["required"]=="true"?"1":"0";

        if(
$question["type"] != "header"){
            
$sql        "insert into question (campaign_id, `name`, `type`, `label`, option_label, option_value, sort, createdate, createby, required) values (?,?,?,?,?,?,?,?,?,?)";
            
$parameters = array((int)$_POST["campaign_id"], $question["name"], $question["type"], $question["label"], implode("*"$question["option"]["label"]), implode("*"$question["option"]["value"]), $sort$nowdate$_SESSION['cmsloginid'], $required);
            
bind_pdo($sql$parameters);

            
$sort++;
        }
    }

    
$sql        "update campaign set form_html=?, form_xml=? where id = ?";
    
$parameters = array($_POST["form_html"], $form_xml, (int)$_POST["campaign_id"]);
    
bind_pdo($sql$parameters);

    echo 
"SUCCESS";

    
//header("Location:  campaign_index.php?msg=1");