I have found a lot of answers to this matter, but did not found working solution for my form posting with $.post to a php file which stores data into a csv file.
The formData gets serialized in another function which stores the data in a const for storing localy. The actually $.post gets done in this part of code.
jQuery code:
function submit(formData) {
function passVal(){
$.post(
"post.php",
formData,
function(formData,status,xhr){
}
);
return false;
}
passVal();
}
PHP Code:
$obj = $_POST;
$retailer = $obj['retailer'];
$question1 = $obj['question1'];
$offline = $obj['offline'];
$question2_1 = $obj['question2_1'];
$question2_2 = $obj['question2_2'];
$question2_3 = $obj['question2_3'];
$question3 = $obj['question3'];
$timestamp = $formdata['timestamp'];
$old_file = fopen('/output/results.csv', 'a');
$list = array
(
$retailer . ';' . $question1 . ';' . $question2_1 . ';' . $question2_2 . ';' . $question2_3 . ';' . $question3 . ';' . $offline . ';' .$timestamp
);
fputcsv($old_file, $list);
fclose($old_file);
Is there a working solution? These answers: Can't retrieve jQuery serialized form data with PHP $_POST[] variable Do not work for me.
I wanted to get the data into the different $vars in php?