在jquery ajax表单帖子的成功部分。 php代码正在发回给我
<?
?>{"Status":"Login Success"}
php代码如下
<?php
header('Content-type: application/json');
//Load DB Connection
require('Global.php');
require('dbConnect.php');
require('Studio7WebClass.php');
//Get form data
$username = $_POST['user'];
$password = $_POST['pass'];
$returnJSON = array('Status'=>'');
$finalJSON = "";
$Studio7Current = new Studio7Web;
$Studio7Current->set_username($username);
try{
$statement = $conn->prepare("select * from Users where (Username = :name OR EmailAddress = :name)");
$statement->execute(array(':name' => $username));
$row = $statement->fetch();
if (is_null($row)){
$returnJSON['Status'] = "User Not Found";
$finalJSON = json_encode($returnJSON);
}
else{
//Now check if the password matches the one the user entered.
if($row['password'] == $password){
//Passwords match
$returnJSON['Status'] = "Login Success";
$finalJSON = json_encode($returnJSON);
}else{
$returnJSON['Status'] = "Password Error";
$finalJSON = json_encode($returnJSON);
}
}
}catch(PDOException $e){
$returnJSON['Status'] = $e->getMessage();
$finalJSON = json_encode($returnJSON);
file_put_contents('PDOErrors.txt', $e->getMessage(), FILE_APPEND);
}
echo $finalJSON;
?>
我不知道为什么我会得到它给出的回应。请帮忙
答案 0 :(得分:0)
由于此文件使用<?php
而不仅仅<?
作为开始标记,因此输出来自另一个文件。您可以找到该文件并删除这5行,也可以启用短标记(请参阅How to enable PHP short tags?)。