I have a simple PHP form containing two (2) textboxes a dropdownlist and finally a SUBMIT button. In this form, before hitting the Submit button, the user has to select an item from the dropdown list. Upon selection of an item from the dropdown list, it's onchange event fires and populates the other 2 textboxes with some data fetched from the database.
The code to fetch data:
var wd_pid = document.getElementById("ddlUnder").value;
var dataString = 'wdpid='+ wd_pid;
$.ajax({
type: "POST",
url: "ldd_pop_wd_pdata.php",
data: dataString,
cache: false,
success: function(result){
var v1= result.substring(0,result.indexOf('='));
var v2= result.substring(result.indexOf('=')+1);
$("#txtMLI").val(v1);
$("#txtMLIURL").val(v2);
}
});
The above code works perfectly, populating the two textboxes with correct data. This forms 'action' attribute points to an another php page containing logic to save form data into the database. My problem begins in the next page. After form submit, in the next php page, the post variables $_POST['txtMLI'] & $_POST['txtMLIURL'] are empty.Why is it so?? Please advise what's going wrong.
Thanks in advance.
POSTvariables are not sessions, they will only exist in the context of the page they where loaded on. If you want to keep a variable stored through many pages you will want to useSESSIONS. Also values are stored based onnameattributes and notid's.