Hi all ive some ajax posting to the same php file to submit the post data to the database, the form data is posting, it just isnt following on to the database :/ way it currently works is that ive a form that submits the form to the PHP then dependant on the resulting factors i put some ajax within a php if statement, which in turns posts back with the action confirm, this post is what i have got up to, i know it posts as the postdata is viewable within firedebug, the problem is, from there it refuses to post that data to my database. Thanks

AJAX in Question:

function AJAX(){
      var override = confirm('<?=$customrule['misc']?> \nDo you wish to override this rule?');
      params= 'ajaxdate=<?=$date?>&ajaxenddate=<?=$enddate?>&ajaxmaxhols=<?=$maxhols?>&ajaxstafforjob=<?=$stafforjob?>&ajaxjobtitle=<?=addslashes($jobtitle)?>&ajaxname=<?=addslashes($name)?>&ajaxuserclient=<?=$userclient?>&ajaxdescription=<?=addslashes($_POST['description'])?>&ajaxportaluserid=<?=$portaluserid?>&action=confirm';
      if (window.XMLHttpRequest) {
      xmlhttp=new XMLHttpRequest();
      } else {
      xmlhttp=new ActiveXObject('MicrosoftXMLHTTP');
      xmlhttp.onreadystatechange=function() {
      if (xmlhttp.readyState==4 && xmlhttp.status == 200) {}
      xmlhttp.open('POST', 'cal_events.php', true);
      xmlhttp.setRequestHeader('Content-type', 'application/x-www-form-urlencoded');
      xmlhttp.setRequestHeader('Content-length', params.length);
      xmlhttp.setRequestHeader('Connection', 'close');
      } else { alert('Action Cancelled!');}}


  $exception = true;
    $date = $_POST['ajaxdate'];
    $enddate = $_POST['ajaxenddate'];
    $maxhols = $_POST['ajaxmaxhols'];
     $daystobookoff = workingDays($date,$enddate);
     $daysallowedoff = $maxhols;
     $overbooked = $stafforjob - $maxhols;
    if(count(workingDays($date,$enddate)) > $daysallowedoff && $exception=false){
     echo "<script>alert('Trying to book more holidays than they are allowed');</script>";
    } else {
     echo "<script>alert('Calendar event added!');</script>";
     foreach($daystobookoff as $day){
      mysql_query("INSERT INTO cal_events (date,jobtitle,emp_id,clientid,description,userid) VALUES ('{$day}','{$_POST['ajaxjobtitle']}','".$_POST['ajaxname']."','{$_POST['ajaxuserclient']}','". $_POST['ajaxdescription'] . "','{$_POST['ajaxportaluserid']}')");
      echo "<script>alert(\"INSERT INTO cal_events (date,jobtitle,emp_id,clientid,description,userid) VALUES ('{$_POST['day']}','{$_POST['jobtitle']}','".$_POST['name']."','{$_POST['userclient']}','". $_POST['description'] . "','{$_POST['portaluserid']}')\");</script>";


Could you have a datatype mismatch? For instance, the third column in your INSERT INTO statement is for emp_id. However, you are sending data in a variable called "ajaxname". If the database is expecting an integer, but you are supplying a string..that would be a problem.

I would recommend that you validate that your INSERT INTO statement is working first, outside of this process. If that works, open the scope of the troubleshooting.

%ajaxname is referencing an employee number placed in the value of a select box :D