/var/www/hkosl.com/survey_demo/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
<?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;
    }

    
$result fn_parse_form_data($_POST["form_xml"]);

    
//var_dump($result);

    //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) {
        
$sql        "insert into question (campaign_id, `name`, `type`, `label`, option_label, option_value, sort, createdate, createby) 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']);
        
bind_pdo($sql$parameters);

        
$sort++;
    }

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

    echo 
"SUCCESS";

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