![]() Server : Apache/2 System : Linux server-15-235-50-60 5.15.0-164-generic #174-Ubuntu SMP Fri Nov 14 20:25:16 UTC 2025 x86_64 User : gositeme ( 1004) PHP Version : 8.2.29 Disable Function : exec,system,passthru,shell_exec,proc_close,proc_open,dl,popen,show_source,posix_kill,posix_mkfifo,posix_getpwuid,posix_setpgid,posix_setsid,posix_setuid,posix_setgid,posix_seteuid,posix_setegid,posix_uname Directory : /home/gositeme/.cursor-server/data/User/History/-101f97f1/ |
<?php
session_start();
// Check if user is logged in
if (!isset($_SESSION['user_id'])) {
echo "<h2>โ Not Logged In</h2>";
echo "<p>Please <a href='/auth/login_new.php'>login</a> to test profile editing.</p>";
exit;
}
echo "<h2>๐งช Profile Edit Test</h2>";
echo "<p>Testing profile editing for user ID: " . $_SESSION['user_id'] . "</p>";
// Test 1: Check if API endpoints exist
echo "<h3>1. API Endpoint Check</h3>";
$update_api = file_exists('api/update_profile.php');
$upload_api = file_exists('api/upload_profile_image.php');
echo "โ
Update Profile API: " . ($update_api ? 'EXISTS' : 'MISSING') . "<br>";
echo "โ
Upload Image API: " . ($upload_api ? 'EXISTS' : 'MISSING') . "<br>";
// Test 2: Check uploads directory
echo "<h3>2. Upload Directory Check</h3>";
$upload_dir = 'uploads/profile_images/';
$dir_exists = is_dir($upload_dir);
$dir_writable = is_writable($upload_dir);
echo "โ
Upload Directory: " . ($dir_exists ? 'EXISTS' : 'MISSING') . "<br>";
echo "โ
Directory Writable: " . ($dir_writable ? 'YES' : 'NO') . "<br>";
// Test 3: Check database connection
echo "<h3>3. Database Connection Test</h3>";
try {
require_once 'config/database.php';
$pdo = getDBConnection();
if ($pdo) {
echo "โ
Database connection: SUCCESS<br>";
// Check if user exists
$stmt = $pdo->prepare("SELECT name, profile_image FROM users WHERE id = ?");
$stmt->execute([$_SESSION['user_id']]);
$user = $stmt->fetch();
if ($user) {
echo "โ
User found: " . htmlspecialchars($user['name']) . "<br>";
echo "โ
Profile image: " . ($user['profile_image'] ? 'SET' : 'NOT SET') . "<br>";
} else {
echo "โ User not found in database<br>";
}
} else {
echo "โ Database connection: FAILED<br>";
}
} catch (Exception $e) {
echo "โ Database error: " . $e->getMessage() . "<br>";
}
// Test 4: Check user_profiles table
echo "<h3>4. User Profiles Table Check</h3>";
try {
$stmt = $pdo->prepare("SELECT COUNT(*) as count FROM user_profiles WHERE user_id = ?");
$stmt->execute([$_SESSION['user_id']]);
$profile_count = $stmt->fetch()['count'];
echo "โ
User profile record: " . ($profile_count > 0 ? 'EXISTS' : 'MISSING') . "<br>";
} catch (Exception $e) {
echo "โ User profiles table error: " . $e->getMessage() . "<br>";
}
echo "<h3>5. Test Links</h3>";
echo "<a href='/artist_profile.php?id=" . $_SESSION['user_id'] . "' target='_blank'>๐ Go to Your Profile</a><br>";
echo "<a href='/api/update_profile.php' target='_blank'>๐ Test Update API</a><br>";
echo "<a href='/api/upload_profile_image.php' target='_blank'>๐ Test Upload API</a><br>";
echo "<h3>6. Manual API Test</h3>";
echo "<p>Test the update API with this curl command:</p>";
echo "<code>curl -X POST /api/update_profile.php -H 'Content-Type: application/json' -d '{\"name\":\"Test User\",\"location\":\"Test City\",\"bio\":\"Test bio\"}'</code>";
echo "<br><br><a href='/index.php'>๐ Return to Homepage</a>";
?>