0

Below is a script through which I am trying to send two parameters: 'badge' and 'srnum' to name2.php.

$('input.accept').on('click',function(){

   var badge= $(this).attr('id');
   var srnum = $(this).attr('name');
   //alert(badge+""+srnum);
   $.post('name2.php',{badge:badge,srnum:srnum},function(data){
         $('td#status').text(data);
        });

});

name2.php -:

<?php
  $badge = $_POST['badge'];
  $srnum = $_POST['srnum'];;
  $connection = oci_connect("","","");
  $main_query=oci_parse($connection,"UPDATE LEAVEINFO1 SET LEAD='Approved' WHERE BADGE='$badge' AND SRNUM='$srnum'");
  oci_execute($main_query);
  oci_close($connection);
?>

Now, here I am not able to post 2 variables using the ajax script to name2.php. Any help as to how should I post 2 or more variables and receive them in the corresponding name2.php script.

1 Answers1

-1

You are sending the variables correctly, but not accessing them in php the correct way. You can test this by doing var_dump($variable) to be sure you are receiving data. Since this is an ajax request, the var_dump results will show in the network tab of the console.

<?php
  $badge = $_POST['badge'];
  $srnum = $_POST['srnum'];
  $connection = oci_connect("","","");
  $main_query=oci_parse($connection,"UPDATE LEAVEINFO1 SET LEAD='Approved' WHERE BADGE='".$badge."' AND SRNUM='".$srnum."'");
  oci_execute($main_query);
  oci_close($connection);
?>

Be sure you are concatenating your strings correctly, using ".$var.", with " or ' being the starting quotation.

acupofjose
  • 2,159
  • 1
  • 22
  • 40