![]() 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/domains/soundstudiopro.com/public_html/ |
<?php
require_once 'config/database.php';
echo "<h2>Test Edit Track Functionality</h2>";
try {
$pdo = getDBConnection();
// Get a track to test with
$stmt = $pdo->query("
SELECT
id,
title,
description,
price,
is_public,
user_id
FROM music_tracks
WHERE status = 'complete'
LIMIT 1
");
$track = $stmt->fetch();
if ($track) {
echo "<p><strong>Testing with track:</strong> " . htmlspecialchars($track['title']) . " (ID: {$track['id']})</p>";
echo "<p><strong>Current price:</strong> " . var_export($track['price'], true) . "</p>";
echo "<p><strong>Current description:</strong> " . htmlspecialchars($track['description']) . "</p>";
echo "<p><strong>Current is_public:</strong> " . var_export($track['is_public'], true) . "</p>";
// Test the edit button call
echo "<h3>Edit Button Call:</h3>";
echo "<code>editTrack({$track['id']}, '" . addslashes($track['title']) . "', '" . addslashes($track['description'] ?? '') . "', '{$track['price']}', {$track['is_public']})</code>";
// Test form data collection
echo "<h3>Form Data Test:</h3>";
echo "<form id='testForm'>";
echo "<div><label>Title: <input type='text' name='title' value='" . htmlspecialchars($track['title']) . "'></label></div>";
echo "<div><label>Description: <textarea name='description'>" . htmlspecialchars($track['description'] ?? '') . "</textarea></label></div>";
echo "<div><label>Price: <input type='number' name='price' value='{$track['price']}' step='0.01'></label></div>";
echo "<div><label><input type='checkbox' name='is_public' " . ($track['is_public'] ? 'checked' : '') . "> Is Public</label></div>";
echo "<button type='button' onclick='testFormData()'>Test Form Data</button>";
echo "</form>";
echo "<div id='formDataResult'></div>";
} else {
echo "<p><strong>❌ No tracks found to test with</strong></p>";
}
} catch (Exception $e) {
echo "<p><strong>❌ Error:</strong> " . htmlspecialchars($e->getMessage()) . "</p>";
}
?>
<script>
function testFormData() {
const form = document.getElementById('testForm');
const formData = new FormData(form);
const result = {
title: formData.get('title'),
description: formData.get('description'),
price: formData.get('price'),
is_public: formData.get('is_public') === 'on' ? 1 : 0
};
document.getElementById('formDataResult').innerHTML = `
<h4>Form Data Collected:</h4>
<pre>${JSON.stringify(result, null, 2)}</pre>
`;
console.log('Form data test:', result);
}
</script>