hey there i have an issue with my php coding i think, i am getting SyntaxError: Unexpected token < in JSON at position 0
during the success part of a jquery ajax form post. the php code is sending me back
<?
?>{"Status":"Login Success"}
the php code is as follows
<?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;
?>
i have no idea why im getting the response it gives. please help