After checking with recaptcha I want to send info to another page. If I print in the console the info they are visible but if I send that and I get by post they are undefined
var payload = {
name: '<?php echo $name ?>',
email: '<?php echo $email ?>'
};
console.table(payload);
var form = document.createElement('form');
form.style.visibility = 'hidden'; // no user interaction is necessary
form.method = 'POST'; // forms by default use GET query strings
form.action = 'test.php';
for (key in Object.keys(payload)) {
var input = document.createElement('input');
input.name = key;
input.value = payload[key];
form.appendChild(input); // add key/value pair to form
}
document.body.appendChild(form); // forms cannot be submitted outside of body
form.submit(); // send the payload and navigate