cannot get id from ajax

10
February 11, 2019, at 08:20 AM

I can't get the id from the js file, I don't know if the js code or the php code is wrong. Can someone help? problem seems to be from index.js. I can get all data except id.

below is the code, I have tried to not use js code and it works fine. Because I need to submit the form without refresh the page, so I use js instead.

index.js

function update(form){
var xml;
if(window.ActiveXObject){
    xml=new ActiveXObject('Microsoft.XMLHTTP');
}else if(window.XMLHttpRequest){
    xml=new XMLHttpRequest();
}
var id=form.id.value;
var city=form.city.value;
var gp_name=form.gp_name.value;
var arrange=form.arrange.value;
var qua=form.qua.value;
xml.open("GET","update_ok.php?id="+id+"&city="+city+"&gp_name="+gp_name+"&arrange="+arrange+"&qua="+qua,true);
xml.onreadystatechange=function(){
    if(xml.readyState==4&&xml.status==200){
        var msg=xml.responseText;
        if(msg==1){
            alert("Update succeed!!");
            location.href='update.php?' + 'gp_name=' + gp_name;
        }else{
            alert("Update False");
            return false;
        }
    }
}
xml.send(null);
}

update_ok.php

<?php
header("Content-Type: text/html; charset=utf-8");
include("connMysql.php");
$seldb = @mysql_select_db("phpmember");
if (!$seldb) die("connection falseļ¼");
$id=$_GET['id'];
$gp_name=$_GET['gp_name'];
$arrange=$_GET['arrange'];
$city=$_GET['city'];
$qua=$_GET['qua'];
$sql=mysql_query("update gp_info set gp_name = '$gp_name', city = '$city', qua = '$qua', arrange = '$arrange' where id='".$_GET["id"]."'");
if($sql){
    $reback=1;
}else{
$reback=0;
}
echo $reback;
?>
READ ALSO
Inserting 2 rows instead of one: angular and php

Inserting 2 rows instead of one: angular and php

I am working with angular 6 and phpWhen i add an entity whith my application, i find that the backend is inserting 2 rows in the table instead of one

34
Merge dataframes by left join SQL &amp; Pandas

Merge dataframes by left join SQL & Pandas

I made two tables into a MySQL database using PythonThe following SQL code is to perform join on two tables in the database

43
Using an auto_increment sequence for cursor purpose in mysql ? Any other Alternative?

Using an auto_increment sequence for cursor purpose in mysql ? Any other Alternative?

I m creating a application where there are users and posts, and user can likes posts, so i have created a table ,

19