I've got a form submission via AJAX that goes thus
Code: Select all
function submitEdits(){
if(validate()){
var frm = document.forms.frmSchoolHistory;
var el = document.createElement("input");
el.type = "hidden";
el.name = "save";
el.value = "yes";
$("[name='frmSchoolHistory']").append(el);
el = document.createElement("input");
el.type = "hidden";
el.name = "q";
el.value = histID;
$("[name='frmSchoolHistory']").append(el);
$.ajax({
url:"updateSchoolHistory.php",
data:$("[name='frmSchoolHistory']").serialize(),
success:(function(data) { alert(data); }),
fail:(function(data) { alert(data); })
})
}
}
Code: Select all
<?php session_start();
require_once '../classes/DBConnection.php';
require '../classes/Applicant.php';
$applicant = new Applicant();
$query .= "select count(*) from ";
$bindsArray = array();
$bindsArray[] = $_SESSION["user"];
if(!isset($_POST['q']) || "0" == $_POST['q']){
$query .= "MY_TABLE where userid=?";
}else{
$query .= "ANOTHER_TABLE where userid=? and histid=?";
$bindsArray[] = $_POST['q'];
}
/*
$conn = new DBConnection();
if(0 < $conn->getRowCount($query, $bindsArray)){
$histId = $applicant->updateSchoolHistory($histId, $_SESSION['user']);
}
*/
?>
schoolName is <?php echo $_POST['schoolName'];?>
Help...?