我在一个单独的文件中有一些 php 代码,并使用 javascript 调用它。但是php代码不起作用。相反,它只是将代码放在 div 中。就像完整的代码在 div 中一样。我怎样才能让这个php代码执行
我的 javascript 函数如下所示:
function checklogin(){
var xmlhttp;
if (window.XMLHttpRequest)
{
xmlhttp=new XMLHttpRequest();
}
xmlhttp.onreadystatechange=function()
{
if (xmlhttp.readyState==4 && xmlhttp.status==200)
{
if(xmlhttp.responseText='FAILED')
{alert('failed');};
}
}
var Usrname
Usrname=document.getElementById("edtLoginUsername").text;
xmlhttp.open("GET","DatabaseFunctions.php?Username="+Usrname,true);
xmlhttp.send();};
我的 PHP 代码如下所示:
<?php
$myServer = "example.com";
$myUser = "dbuser";
$myPass = "dbpass";
$myDB = "efarm";
//connection to the database
$dbhandle = mssql_connect($myServer, $myUser, $myPass)
or die("Couldn't connect to SQL Server on $myServer");
//select a database to work with
$selected = mssql_select_db($myDB, $dbhandle)
or die("Couldn't open database $myDB");
//declare the SQL statement that will query the database
$query = "SELECT COUNT(*) FROM Users WHERE Username=myQuoteString('$_GET(USERNAME)')'";
//execute the SQL query and return records
$result = mssql_query($query);
echo 'FAILED';
//close the connection
mssql_close($dbhandle);
?>
我已经检查了我的 httpd.conf 文件并检查了 php 是否已安装和配置