Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/278.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript Ajax错误:不返回数据库值_Javascript_Php_Html_Ajax - Fatal编程技术网

Javascript Ajax错误:不返回数据库值

Javascript Ajax错误:不返回数据库值,javascript,php,html,ajax,Javascript,Php,Html,Ajax,我的ajax php编码有问题。 问题是当用户输入密码登录时,live Check功能输出仅在下面的选择框中显示为空,而不是数据库中的数据。 下面是我的代码: Login.php username:<input type="text" class="name" id="uname" placeholder="enter your username here"><br> password:<input type="password" class="pass" id="

我的ajax php编码有问题。 问题是当用户输入密码登录时,live Check功能输出仅在下面的选择框中显示为空,而不是数据库中的数据。 下面是我的代码:

Login.php

username:<input type="text" class="name" id="uname" placeholder="enter your username here"><br>
password:<input type="password" class="pass" id="pword" placeholder="password here"><br>
<div id="txt">
   responsibility:<select id="opti">
        <option value=""> Select your responsibility</option>
</select><br></div>


<script>
function showUser(str) {
   if (str == "") {
    document.getElementById("txt").innerHTML = "";
    return;
} else {
    if (window.XMLHttpRequest) {
        // code for IE7+, Firefox, Chrome, Opera, Safari
        xmlhttp = new XMLHttpRequest();
    } else {
        // code for IE6, IE5
        xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
    }
    xmlhttp.onreadystatechange = function() {
        if (this.readyState == 4 && this.status == 200) {
            document.getElementById("txt").innerHTML = this.responseText;
        }
    };
    xmlhttp.open("POST","dblogin.php?q="+str,true);
    xmlhttp.send();
   }
}
document.getElementById('pword').addEventListener("keyup", function(str) {
    showUser(str);
}, false);
</script>
用户名:
密码:
责任: 选择你的责任
函数showUser(str){ 如果(str==“”){ document.getElementById(“txt”).innerHTML=“”; 返回; }否则{ if(window.XMLHttpRequest){ //IE7+、Firefox、Chrome、Opera、Safari的代码 xmlhttp=新的XMLHttpRequest(); }否则{ //IE6、IE5的代码 xmlhttp=新的ActiveXObject(“Microsoft.xmlhttp”); } xmlhttp.onreadystatechange=函数(){ if(this.readyState==4&&this.status==200){ document.getElementById(“txt”).innerHTML=this.responseText; } }; open(“POST”,“dblogin.php?q=“+str,true”); xmlhttp.send(); } } document.getElementById('pword')。addEventListener(“键控”,函数(str){ showUser(str); },假);
Dblogin.php

<?
$q=intval($_POST["pword"]);

require ("config.php");
$link=mysqli_connect($host,$user,$pass,$db);

$query="select responsibility from testing where password = '".$q."'";
$result=mysqli_query($link,$query);
    if($result){
?>
<form>
responsibility:<select id="opti">
<?
    while($row=mysqli_fetch_array($result))
    echo"<option value='$row[1]'>$row[1]</option>";
?>
</select>
<input type=submit value ="submit">
<?
}
else
{
?>
Error:No Data Found
<?
}
?>
xmlhttp.send()-您没有发送任何post数据-您可以更改获取的方法,并且
$q=intval($\u GET[“q”])
xmlhttp.send()-您没有发送任何post数据-您可以更改获取的方法,并且
$q=intval($\u GET[“q”])
<?
   $host="localhost";
   $db="logindb"
   $user="root"
   $pass="";
?>