
PK 
<?php
// COMPLETE CLEAN SLATE APPROACH
function cleanOutput() {
while (ob_get_level() > 0) {
ob_end_clean();
}
ob_start();
}
function sendJSON($data) {
cleanOutput();
header('Content-Type: application/json');
echo json_encode($data);
ob_end_flush();
exit;
}
// Start fresh
cleanOutput();
// Basic settings
error_reporting(0);
ini_set('display_errors', 0);
// Start session
if (session_status() !== PHP_SESSION_ACTIVE) {
session_start();
}
// Get POST data
$username = isset($_POST['username']) ? trim($_POST['username']) : '';
$password = isset($_POST['password']) ? trim($_POST['password']) : '';
// Validate input
if (empty($username) || empty($password)) {
sendJSON(["status" => "error", "message" => "Please enter username and password"]);
}
// Manual database connection to avoid include issues
try {
// Replace with your actual database credentials
$host = 'localhost';
$dbname = 'questend_rwaSector40';
$user = 'questend_usrRWA';
$pass = 'FPq.6fR~30t7%m+FLXzw=;,3';
$pdo = new PDO("mysql:host=$host;dbname=$dbname", $user, $pass);
$pdo->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
$password_hash = md5($password);
$stmt = $pdo->prepare("SELECT * FROM users WHERE mobile = ? AND password = ? AND isactive = '1'");
$stmt->execute([$username, $password_hash]);
$user = $stmt->fetch(PDO::FETCH_ASSOC);
if ($user) {
$_SESSION['userId'] = $user['id'];
$_SESSION['userLoggedIn'] = true;
setcookie("remember_user", $user['id'], time() + (86400 * 30), "/");
sendJSON(["status" => "success"]);
} else {
sendJSON(["status" => "error", "message" => "Invalid username or password"]);
}
} catch (PDOException $e) {
sendJSON(["status" => "error", "message" => "Database connection failed"]);
} catch (Exception $e) {
sendJSON(["status" => "error", "message" => "System error"]);
}
?>


PK 99