views:

53

answers:

2

I have a local variable I'd like to be sent along with the rest of the POST data taken from an HTML form. Is there a function that lets me put more data from the current page into the POST array?

+2  A: 

no function, simply add a hidden field with the value.

<input type='hidden' name='what_ever' value='<?php echo $my_var?>' />

If you need the value to remain totally hidden from the user, then use the SESSION to pass it's value between requests.

Itay Moav
+1  A: 

I am assuming that when you say "local data" you mean client side data. You could do this with some javascript.

function addFormData(key, name) {
var f = document.getElementById('myform');
var g = document.createElement('input');
g.setAttribute('name', key);
g.setAttribute('type', 'hidden');
g.value = name;
f.appendChild(g);
f.submit();
}
Glenn