Answer the question
In order to leave comments, you need to log in
Need help with PHP array manipulation?
Help with PHP
sending an array
$.ajax({
url: 'scripts/order.php',
data: orderData,
type: 'POST',
cache: false,
dataType: 'json',
error: _orderError,
success: function(responce) {
if (responce.code === 'success') {
_orderSuccess(responce);
} else {
_orderError(responce);
}
},
complete: _orderComplete
});
function getParam($param) {
return (isset($_POST[$param]));
}
function getData() {
return array(
'surname' => getParam('surname'),
'name' => getParam('name'),
'email' => getParam('email'),
'phone' => getParam('phone'),
'coment' => getParam('coment'),
'cart' => isset($_POST['cart']) ? ($_POST['cart']) : '[]'
);
}
Answer the question
In order to leave comments, you need to log in
For example
function getData() {
return array(
'surname' => filter_input(INPUT_POST, 'surname', FILTER_SANITIZE_STRING),
'name' => filter_input(INPUT_POST, 'name', FILTER_SANITIZE_STRING),
'email' => filter_input(INPUT_POST, 'email', FILTER_VALIDATE_EMAIL),
'phone' => filter_input(INPUT_POST, 'phone', FILTER_SANITIZE_STRING),
'comment' => filter_input(INPUT_POST, 'comment', FILTER_SANITIZE_STRING),
'cart' => json_decode(filter_input(INPUT_POST, 'comment', FILTER_SANITIZE_STRING) ?: '[]'),
);
}
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question