I need help on this code. I want to dynamically prohibit a user from adding to cart if the requested stock item (Database) is less than his request (qty). Will appreciate, if I can know where I am wrong and probably someone correct it for me.
HTML FORM
<form action="cart.php?adm_id=<?php echo urlencode($patient["adm_id"]);?>" method="post" name="CartForm" target="_self">
<p>Product Name:<select name="prod_name" size="1" id="prod_name">
<option value="Select">Select</option>
<?php
while ($line = mysqli_fetch_array($query, MYSQL_ASSOC)) {
?>
<option value="<?php echo $line['prod_name'];?>"> <?php echo $line['prod_name'];?> </option>
<?php } ?>
</select></p>
<p>Quantity:<input type="number" name="qty" id="qty" size="30" required="required"/></p>
<input name="submit" type="submit" value="Add to Cart" id="btn"/> | <input name="reset" type="reset" value="Cancel" />
Ajax Code:
<script src="javascript/jquery-2.0.3.js">
</script>
<script type="text/javascript">
$(document).ready(function(ex) {
//$('#stock').load('pharmacy_summary.php');
$('#qty').change(function(){
var prod_name = $('#prod_name').val();
var qty= $('#qty').val();
$.ajax({
url: 'confirmStock.php',
data:{prod_name: prod_name, qty: qty},
success: function(e){
if(e == 'true'){
/*if the quantity is greater than the stock*/
alert('stock Item is lower to your request, reduce it');
$('#btn').prop('disabled', true);
}else{
$('#btn').prop('disabled', false);
} }
})});
});
</script>
PHP/MYSQLI Code:(ConfirmStock.php)
<?php require_once("/includes/db_connection.php");?>
<?php require_once("/includes/functions.php");?>
<?php
if(isset($_GET['prod_name'])){
$getProd = $_GET['prod_name'];
$getQty = $_GET['units'];
global $connection;
$val = "SELECT * FROM pharmacy_stock_tab WHERE prod_name='".$getProd."'";
$conf = mysqli_query($connection,$val);
$fetchVal = mysqli_fetch_array($conf);
$stock = $fetchVal['units'];
if($getQty>$stock){
return $stock;
}else{
return $stock;
}
}
?>
You must change the way you send response and the way you handle the response. change the code in ConfirmStock.php
change the return statements in following way
$result = array();
if($getQty>$stock){
$result['success'] = 'true';
$result['stock'] = $stock;
}else{
$result['success'] = 'false';
}
header('Content-Type: application/json');
echo json_encode($result);
die();
In Ajax success method
success: function(response){
if(response.success == 'true'){
/*if the quantity is greater than the stock*/
alert('stock Item is lower to your request, reduce it');
$('#btn').prop('disabled', true);
}else{
$('#btn').prop('disabled', false);
} }
Related
I am trying to set up a datalist tag that uses fields from my database based on the input from the first field on the form.
I am trying to use AJAX to send the value in the first field (Builder) into my PHP file which will run a query to pull all the records based on that value. Then it echos the options into the datalist for all the contactnames available under that Builder.
<form id="newsurveyform" method="post" action="submitnewsurvey.php">
ID: <input type="text" name="ID" readonly value=<?php print $auto_id; ?>>
Builder:<b style="color:red">*</b> <input list="builders" name="builders" onchange="findcontactnames(this.value)" required>
<datalist id="builders">
<?php
while ($builderinforow = mysqli_fetch_assoc($builderinfo)){
echo'<option value="'.$builderinforow['Builder'].'">';
}
?>
</datalist>
Contact Name:
<input list="contactnames" name="contactnames" required>
<datalist id="contactnames">
<div id="contactnamesoptions"> </div>
</datalist>
</form>
<!-- AJAX, send builder value to php file-->
<script>
function findcontactnames(str) {
if (str.length==0){
document.getElementById("contactnames").innerHTML = "";
return;}
else{
var xmlhttp = new XMLHttpRequest();
xmlhttp.onreadystatechange = function() {
if (this.readyState == 4 && this.status == 200) {
document.getElementById("contactnamesoptions").innerHTML = this.responseText;
}};
xmlhttp.open("POST", "contactnames.php", true)
xmlhttp.send(str);
}
}
</script>
<?php
include 'dbconnector.php';
$buildername = $_POST["Builder"];
$contactnames = $conn->query("SELECT ContactName FROM SurveyLog'.$buildername.'");
while ($contactnamerow = mysqli_fetch_assoc($contactnames)){
echo'<option value="'.$contactnamerow['ContactName'].'">';
}
?>
Once the user enters the builder, they will click the contact name and it should be populated with all the contact names under that builder.
Right now, it is not populating anything into the contact name field.
In index.php
<form id="newsurveyform" method="post" action="submitnewsurvey.php">
ID: <input type="text" name="ID" readonly value=<?php print $auto_id ?? 0; ?>>
Builder:<b style="color:red">*</b> <input list="builders" name="builders" onchange="findcontactnames(this.value)" required>
<datalist id="builders">
<?php
while ($builderinforow = mysqli_fetch_assoc($builderinfo)){
echo'<option value="'.$builderinforow['Builder'].'">';
}
?>
</datalist>
Contact Name:
<input list="contactnames" name="contactnames" required>
<datalist id="contactnames">
<div id="contactnamesoptions"> </div>
</datalist>
</form>
<!-- AJAX, send builder value to php file-->
<script>
function findcontactnames(str) {
if (str.length==0){
document.getElementById("contactnames").innerHTML = "";
return;
} else {
var xmlhttp = new XMLHttpRequest();
xmlhttp.onreadystatechange = function() {
console.log(this);
if (this.readyState == 4 && this.status == 200) {
alert('Fired');
document.getElementById("contactnamesoptions").innerHTML = this.responseText;
// document.getElementById("contactnamesoptions").innerHTML = "working";
}
};
xmlhttp.open("POST", "response.php", true)
xmlhttp.send(str);
}
}
</script>
in response.php
<?php echo "test"; ?>
Once you've verified that works, query the database
EDIT:
Now that you've verified that, query the database in response.php
include 'dbconnector.php';
$buildername = $_POST["Builder"];
$contactnames = $conn->query("SELECT ContactName FROM SurveyLog WHERE `columnName` LIKE '.$buildername.' LIMIT 100");
$queryHTML = '';
$result = 0;
while ($contactnamerow = mysqli_fetch_assoc($contactnames)){
$result = 1;
$queryHTML .= '<option value="'.$contactnamerow['ContactName'].'">';
}
if ($result == 1) {
echo $queryHTML;
} else {
echo 'No Builders found';
}
Note: Change the columnName in the query to your real column name
Apologies for similarities between this post and my previous one. I'd appreciate if someone could help me once again spot where I'm going wrong. Everything else appears to be working fine but what is puzzling me is the 'quiet' response on the AJAX success function. Nothing in the console either.
I've tested the JSON output with the json_encode and print_r functions and got the following - so I presume the JSON string should be ok to work with the AJAX:
Array
(
[proj_start_date] => 2017-04-17
[proj_end_date] => 2018-04-30
[wo_nbr_new] => 10002-06
)
{"proj_start_date":"2017-04-17","proj_end_date":"2018-04-30","wo_nbr_new":"10002-06"}
Below is the code for the main file:
<?php
include 'connect_db.php';
$sql = "SELECT * FROM projects ORDER BY proj_nbr";
$result = mysqli_query($connect,$sql);
$rowCount = mysqli_num_rows($result);
?>
<!DOCTYPE html>
<html lang="en">
<head>
<title>Add New Work Order</title>
<script
src="https://code.jquery.com/jquery-3.2.1.min.js"integrity="sha256-hwg4gsxgFZhOsEEamdOYGBf13FyQuiTwlAQgxVSNgt4="
crossorigin="anonymous">
</script>
<link rel="stylesheet" type="text/css" href="styles.css">
</head>
<body>
<h1>Add New Work Order</h1>
<div id="forms-add" name="forms-add">
<form action="add_workorders.php" method="POST">
<label>Work Order Number (Auto-generated):</label>
<input type="text" id="wo_nbr" name="wo_nbr"size="8"maxlength="8" value = "" readonly style="float: right">
<br><br>
<fieldset>
<legend>Project Details</legend>
<label>Project Number:</label>
<select class= "selects" id="proj_nbr" name="proj_nbr" required onchange="">
<option value="">Select a project </option>
<?php
if($rowCount>0)
{
while ($row=mysqli_fetch_assoc($result))
{
echo '<option value="'.
$row['proj_id'].'">'.
$row['proj_nbr'].
' - '.
$row['proj_desc'].
' </option>';
}
}
else
{
echo '<option value="">Project not available</option>';
}
?>
</select>
<br><br>
<label>Start Date:</label>
<input type="text" id="proj_start_date" name="proj_start_date"size="8"maxlength="8" value = "" readonly style="float: right">
<br><br>
<label>End Date:</label>
<input type="text" id="proj_end_date" name="proj_end_date"size="8"maxlength="8" value = "" readonly style="float: right">
</fieldset>
<br><br>
<button type="submit" name="submit" >Save Work Order</button>
</form>
</div>
</body>
<script type="text/javascript" src="test_ajax.js"></script>
<script>
$(document).ready(function()
{
$('#proj_nbr').change(function()
{
var id=$('#proj_nbr').val();
//alert(id); //this works ok
if (id != '')
{
$.ajax({
url: "get_proj_nbrs2.php",
method:"POST",
data: {id:id}, //data to SEND to PHP file
dataType: "JSON",
success: function(output)
{
console.log(output); //this doesn't return anything in the console??
$('#wo_nbr').val(output.wo_nbr_new);
$('#proj_start_date').val(output.proj_start_date);
$('#proj_end_date').val(output.proj_end_date);
}
});
}
else
{
alert("Please select a Project");
}
});
});
</script>
</html>
And the following is the code in the PHP file:
<?php
include 'connect_db.php';
if (isset($_POST['id']) && !empty($_POST['id']))
{
$sql2 = "SELECT p.proj_nbr as wo_proj_nbr,p.start_date as proj_start_date,p.end_date as proj_end_date, MAX(w.wo_nbr) AS wo_nbr,
CASE WHEN SUBSTRING(MAX(w.wo_nbr),7,2)+1 <= 9 THEN CONCAT(p.proj_nbr,'-0',SUBSTRING(MAX(w.wo_nbr),7,2)+1)
ELSE CONCAT(p.proj_nbr,'-',SUBSTRING(MAX(w.wo_nbr),7,2)+1) END AS wo_nbr_new
FROM workorders as w
INNER JOIN projects as p on p.proj_id = w.proj_id
WHERE w.proj_id = '".$_POST['id']."'";
$result2 = mysqli_query($connect,$sql2);
while($row=mysqli_fetch_array($result2))
{
if($result2 ==true)
{
$proj_nbr = $row['wo_proj_nbr'];
$output['proj_start_date'] = $row['proj_start_date'];
$output['proj_end_date'] = $row['proj_end_date'];
if ($row['wo_nbr_new'] != NULL)
{
$output['wo_nbr_new'] = $row['wo_nbr_new'];
echo json_encode($output);
}
elseif($row['wo_nbr_new'] == NULL)
{
$output['wo_nbr_new'] = $proj_nbr."-01";
echo json_encode($output);
}
}
}
}?>
<?php
include 'connect_db.php';
if (isset($_POST['id']) && !empty($_POST['id']))
{
$result = array();
$sql2 = "SELECT p.proj_nbr as wo_proj_nbr,p.start_date as proj_start_date,p.end_date as proj_end_date, MAX(w.wo_nbr) AS wo_nbr,
CASE WHEN SUBSTRING(MAX(w.wo_nbr),7,2)+1 <= 9 THEN CONCAT(p.proj_nbr,'-0',SUBSTRING(MAX(w.wo_nbr),7,2)+1)
ELSE CONCAT(p.proj_nbr,'-',SUBSTRING(MAX(w.wo_nbr),7,2)+1) END AS wo_nbr_new
FROM workorders as w
INNER JOIN projects as p on p.proj_id = w.proj_id
WHERE w.proj_id = '".$_POST['id']."'";
$result2 = mysqli_query($connect,$sql2);
if($result->num_rows > 0)
{
while($row=mysqli_fetch_array($result2))
{
$proj_nbr = $row['wo_proj_nbr'];
$output['proj_start_date'] = $row['proj_start_date'];
$output['proj_end_date'] = $row['proj_end_date'];
if ($row['wo_nbr_new'] != NULL)
{
$output['wo_nbr_new'] = $row['wo_nbr_new'];
}
elseif($row['wo_nbr_new'] == NULL)
{
$output['wo_nbr_new'] = $proj_nbr."-01";
}
array_push($result,$output);
}
echo json_encode($result);
}
else
{
echo "no rows found";
}
}?>
You was echo each row so you will get result from success function in ajax as each separate sting. so it can't parse. hope this method will solve your problem.
Please confirm that you id value is not empty and matches to database field values as well. if so then change the 'id' to 'theid' (might be reserved word) in both the ajax e.g.
data: {theid:id}, //data to SEND to PHP file
and in php e.g.
if (isset($_POST['theid']) && !empty($_POST['theid'])) {
$sql2 = "SELECT p.proj_nbr as wo_proj_nbr,p.start_date as proj_start_date,p.end_date as proj_end_date, MAX(w.wo_nbr) AS wo_nbr,
CASE WHEN SUBSTRING(MAX(w.wo_nbr),7,2)+1 <= 9 THEN CONCAT(p.proj_nbr,'-0',SUBSTRING(MAX(w.wo_nbr),7,2)+1)
ELSE CONCAT(p.proj_nbr,'-',SUBSTRING(MAX(w.wo_nbr),7,2)+1) END AS wo_nbr_new
FROM workorders as w
INNER JOIN projects as p on p.proj_id = w.proj_id
WHERE w.proj_id = '".$_POST['theid']."'";
// code goes here
}
use type at method. method POST depends on jquery version
$.ajax({
url: "get_proj_nbrs2.php",
type:"POST",
data: {id:id}, //data to SEND to PHP file
dataType: "JSON",
success: function(output)
{
}
});
My table is not displayed when i select any project name. I guess the onchange function is not working properly but i couldn't figure out the problem.
Code is as follows:
<div class="span6">
<?php $sql = "SELECT * from login_projects WHERE login_id='".$record['login_id']."'";
$res_sql = mysql_query($sql); ?>
<label>Project Name <span class="f_req">*</span></label>
<!--<input type="text" name="city" class="span8" />-->
<select name="project_name" onchange="get_list_onnet()" id="project_name" class="span8">
<option value="">--</option>
<?php while($rec_sql = mysql_fetch_array($res_sql)){ ?>
<option value="<?php echo $rec_sql['project_id']; ?>">
<?php echo $rec_sql['project_name']; ?></option>
<?php } ?>
</select>
</div>
Function:
<script>
function get_list_onnet(){
var project_name=$("#project_name").val();
$.ajax
({
type: "POST",
url: "ajax.php",
data: {action: 'get_list_onnet',list_onnet:project_name},
success: function()
{
document.getElementById("dt_a").style="block";
$("#dt_a").html(html);
}
});
};
</script>
<script>
$(document).ready(function() {
//* show all elements & remove preloader
setTimeout('$("html").removeClass("js")',1000);
});
</script>
Ajax.Php Page:
function get_list_onnet(){
$list_onnet=$_POST['list_onnet'];
$sql_list_onnet=mysql_query("SELECT * from projects,project_wise_on_net_codes
where projects.project_id = project_wise_on_net_codes.project_id AND
project_wise_on_net_codes.project_id='$list_onnet'");
$row1 = mysql_num_rows($sql_list_onnet);
if($row1>0)
{
echo "<tr><th>id</th><th>Project Name</th><th>Country Code</th><th>On-net prefix</th>
<th>Action</th></tr>";
$k = 1; while($row_list_onnet=mysql_fetch_array($sql_list_onnet))
{
$project3 = $row_list_onnet['project_name'];
$countrycode1 = $row_list_onnet['country_code'];
$prefix1 = $row_list_onnet['on_net_prefix'];
$id_proj = $row_list_onnet['project_id'];
$on_prefix = $row_list_onnet['on_net_prefix'];
echo "<tr><td>".$k."</td><td>".$project3."</td><td>".$countrycode1."</td>
<td>".$prefix1."</td><td><a href='process/update_process_onnet.php?ID=".$id_proj."&Onnet=".$on_prefix."'>Delete</a></td>
</tr>";
$k++;
}
}
else
{
echo "<script>alert('No Record Found')</script>";
}
}
The problem is that it is always going in the else condition and nothing is displayed in the table.
I have a form with some php to validate and insert in the database on submit and the form opens in colorbox.
So far so good. What I'm trying to do is to close colorbox and refresh a div on success.
I guess I need to pass a response to ajax from php if everything OK, close the colorbox with something like setTimeout($.fn.colorbox.close,1000); and refresh the div, but I'm stuck because I'm new in ajax.
I'll appreciate any help here.
Here is my ajax:
jQuery(function(){
jQuery('.cbox-form').colorbox({maxWidth: '75%', onComplete: function(){
cbox_submit();
}});
});
function cbox_submit()
{
jQuery("#pre-process").submit(function(){
jQuery.post(
jQuery(this).attr('action'),
jQuery(this).serialize(),
function(data){
jQuery().colorbox({html: data, onComplete: function(){
cbox_submit();
}});
}
);
return false;
});
}
form php code:
<?php
error_reporting(-1);
include "conf/config.php";
if(isset($_REQUEST['rid'])){$rid=safe($_REQUEST['rid']);}
if(isset($_REQUEST['pid'])){$pid=safe($_REQUEST['pid']);}
$msg = '';
if (!$_SESSION['rest_id']) $_SESSION['rest_id']=$rid; //change to redirect
$session_id=session_id();
if(isset($_REQUEST['submit'])){
if(isset($_POST['opta'])){
$opta=safe($_POST['opta']);
$extraso = implode(',',array_values( array_filter($_POST['opta']) ));
}
if (array_search("", $_POST['opt']) !== false)
{
$msg = "Please select all accessories!";
}else{
$extrasm = implode(',',array_values( array_filter($_POST['opt']) ));
if ($_POST['opt'] && isset($_POST['opta'])) {$extras= $extrasm .",". $extraso;}
if ($_POST['opt'] && !isset($_POST['opta'])) {$extras= $extrasm;}
if (!$_POST['opt'] && isset($_POST['opta'])) {$extras= $extraso;}
$sql['session_id'] = $session_id;
$sql['rest_id'] = $_POST['rid'];
$sql['prod_id'] = $_POST['pid'];
$sql['extras'] = $extras;
$sql['added_date'] = Date("Y-m-d H:i:s");
$newId=insert_sql("cart",$sql);
}
}
?>
<form id="pre-process" action="<?php echo $_SERVER['PHP_SELF']; ?>" method="post">
<div style="background-color:#FFF; padding:20px;">
<?=$msg;?>
<?php
$name = getSqlField("SELECT name FROM products WHERE resid=".$_SESSION['rest_id']." and id=".$pid."","name");
echo "<div style='color:#fff; background-color:#F00;padding:10px;' align='center'><h2>".$name."</h2></div><div style='background-color:#FFF; padding: 20px 70px 30px 70px; '>Please select accessories.<br><br>";
$getRss = mysql_query("SELECT * FROM optional_groups_product where prodid=".$pid." order by id asc");
while ($rsrw = #mysql_fetch_array($getRss)) {
$goptionals = getSqlField("SELECT goptionals FROM optionals_groups WHERE resid=".$_SESSION['rest_id']." and id=".$rsrw['goptid']."","goptionals");
$goptionals=explode(', ',($goptionals));
echo "<select name='opt[]' id='opt[]' style='width:220px;'>";
echo "<option value='' >Select Options</option>";
foreach($goptionals as $v)
{
$vname = mysql_query("SELECT * FROM optionals where id=".$v." LIMIT 0,1");
while ($rsgb = #mysql_fetch_array($vname)) {
$aa=$rsgb['optional'];
}
echo "<option value=".$v." >".$aa."</option>";
}
echo "</select>(required)<br>";
//}
}
$getRss = mysql_query("SELECT * FROM optional_product where prodid=".$pid."");
?>
<br><br>
<table border="0" cellpadding="0" cellspacing="0" >
<tr>
<td bgcolor="#EAFFEC">
<div style="width:440px; ">
<?php
while ($rssp = #mysql_fetch_array($getRss)) {
$optional=getSqlField("SELECT optional FROM optionals WHERE id=".$rssp['optid']."","optional");
$price=getSqlField("SELECT price FROM optionals WHERE id=".$rssp['optid']."","price");
?>
<div style="width:180px;background-color:#EAFFEC; float:left;padding:10px;""><input type="checkbox" name="opta[]" id="opta[]" value="<?=$rssp['optid']?>" /> <i><?=$optional?> [<?=CURRENCY?><?=$price?> ]</i> </div>
<?php } ?>
</div>
</td>
</tr></table>
<input type="hidden" name="rid" value="<?=$rid?>" />
<input type="hidden" name="pid" value="<?=$pid?>"/>
</div><input type="hidden" name="submit" /><input id='submit' class="CSSButton" style="width:120px; float:right;" name='submit' type='submit' value=' Continue ' /><br />
<br /><br />
</div>
</form>
I don't know colobox, but if I understand well what you are trying to do,
I would say your javascript should more look like this
function cbox_submit()
{
jQuery("#pre-process").submit(function(e) {
e.preventDefault(); // prevents the form to reload the page
jQuery.post(
jQuery(this).attr('action')
, jQuery(this).serialize()
, function(data) {
if (data['ok']) { // ok variable received in json
jQuery('#my_colorbox').colorbox.close(); // close the box
}
}
);
return false;
});
}
jQuery(function() {
jQuery('#my_colorbox').colorbox({
maxWidth: '75%'
, onComplete: cbox_submit // Bind the submit event when colorbox is loaded
});
});
You should separate at least your php script that does the post part.
And this php (called with jQuery(this).attr('action')) should return a json ok variable if successfull. Example:
<?php
# ... post part ...
# if success
ob_clean();
header('Content-type: application/json');
echo json_encode(array('ok' => true));
?>
A form contains a dropdown menu on change it should fetch the value from the database using ajax and dislay the checkbox with .
uptil here its wking good,when i submit form the checkbox values is not getting posted.
<form name="test" >
<tr>
<td align="left"><b>System :</b> </td>
<td align="left">
<select name="system" size="1" onchange="regionsa(this.value);" >
<option value="0">Select a System</option>
<?php // Retrieve all the announcement types and add to the pull-down menu.
$q = "SELECT * FROM System";
$r = mysqli_query ($CARE_dbc, $q);
while ($row = mysqli_fetch_array ($r, MYSQLI_NUM)) {
// $sys_name = $edit_menu['system'];
?>
<option value="<? echo $row[1];?>" <? if($row[1]==$edit_menu['system'])
{
echo $selec = "selected";
}?> >
<? echo $row[1];?>
</option>
<? }?>
</select>
</td>
</tr>
<tr>
<td align="left">
<b>User Type :</b> </td>
<td align="left" ><span id="sant">
<?php // Retrieve all the announcement types and add to the pull-down menu.
$qUTdd = "SELECT * FROM `UserType`";
$rUTdd = #mysqli_query ($CARE_dbc, $qUTdd);
while ($rUTddrow = mysqli_fetch_assoc($rUTdd))
{
$utype_qr = mysqli_query($CARE_dbc,"SELECT * FROM `menu_users` WHERE `menu_users`.menu_id='".$_REQUEST['id']."'");
//$ut = mysqli_fetch_assoc($utype_qr);
?>
<input type="checkbox" name="user_type[]" value="<? echo $rUTddrow['idUType'];?>" <? while($ut = mysqli_fetch_assoc($utype_qr))
{
if($ut['user_type']==$rUTddrow['idUType'])
{
echo "checked";
}
}?> /> <?echo "<b>".$rUTddrow['userType']."</b>"; ?>
<?
}
?>
</span>
</td>
</tr>
<input type="submit" name="submit" value="Add" />
<input type="hidden" name="submitted" value="TRUE" />
</form >
<script language="javascript">
var http = createRequestObject();
function createRequestObject()
{
var request_o; //declare the variable to hold the object.
var browser = navigator.appName; //find the browser name
if(browser == "Microsoft Internet Explorer"){
/* Create the object using MSIE's method */
request_o = new ActiveXObject("Microsoft.XMLHTTP");
}else{
/* Create the object using other browser's method */
request_o = new XMLHttpRequest();
}
return request_o; //return the object
}
function regionsa(stateid)
{
//alert(stateid);
http.open('get','internal_request.php?id='+stateid);
http.onreadystatechange = handleresponse;
http.send(null);
}
function handleresponse()
{
if(http.readyState == 4)
{
var response = http.responseText;
//alert(response);
document.getElementById('sant').innerHTML = response;
}
}
</script>
Internal_request.php
<?php
if($_REQUEST['id']=='annmet' && isset($_REQUEST['id']) && !empty($_REQUEST['id']))
{
$qUTdd = "SELECT * FROM annmet.`usertype`";
$rUTdd = #mysqli_query ($CARE_dbc, $qUTdd);
while ($rUTddrow = mysqli_fetch_assoc($rUTdd))
{
$utype_qr = mysqli_query($CARE_dbc,"SELECT * FROM CARE.`menu_users` WHERE CARE.`menu_users`.menu_id='".$_REQUEST['id']."'");
//$ut = mysqli_fetch_assoc($utype_qr);
?>
<input type="checkbox" name="user_type1[]" value="<? echo $rUTddrow['idUType'];?>"
<? while($ut = mysqli_fetch_assoc($utype_qr))
{
if($ut['user_type']==$rUTddrow['idUType'])
{
echo "checked";
}
}?> /> <?echo "<b>".$rUTddrow['UserT']."</b>"; ?>
<?
}
}
?>
name of the AJAX generated checkboxes is user_type*1*[] while original checkbox name is user_type[].
EDIT:
You have not mentioned a value for "method" attribute of Form element. Therefore this form uses default form submission method which is GET. Therefore you don't get any data for $_POST variable. Print $_GET variable using print_r and check.