Sindbad~EG File Manager
<?php
require_once 'config/config.php';
$db = Database::getInstance()->getConnection();
echo "<h2>✓ Verification - Fix Status</h2>";
echo "<hr>";
// Check if member_id UNIQUE index exists
echo "<h3>1. Checking UNIQUE index 'member_id':</h3>";
$stmt = $db->query("SHOW INDEX FROM members WHERE Key_name = 'member_id' AND Non_unique = 0");
$uniqueIndex = $stmt->fetch(PDO::FETCH_ASSOC);
if ($uniqueIndex) {
echo "<p style='color: red;'>❌ UNIQUE index 'member_id' still exists</p>";
} else {
echo "<p style='color: green; font-weight: bold;'>✓ UNIQUE index 'member_id' has been removed (GOOD!)</p>";
}
// Check for empty membership_id
echo "<h3>2. Checking for empty membership_id values:</h3>";
$stmt = $db->query("SELECT COUNT(*) as count FROM members WHERE membership_id = '' OR membership_id IS NULL");
$result = $stmt->fetch();
if ($result['count'] > 0) {
echo "<p style='color: orange;'>⚠ Found {$result['count']} members with empty membership_id</p>";
} else {
echo "<p style='color: green; font-weight: bold;'>✓ No empty membership_id values (GOOD!)</p>";
}
// Check for duplicates
echo "<h3>3. Checking for duplicate membership_id values:</h3>";
$stmt = $db->query("
SELECT COUNT(*) as count
FROM (
SELECT membership_id, COUNT(*) as cnt
FROM members
WHERE membership_id IS NOT NULL AND membership_id != ''
GROUP BY membership_id
HAVING cnt > 1
) as dups
");
$result = $stmt->fetch();
if ($result['count'] > 0) {
echo "<p style='color: orange;'>⚠ Found {$result['count']} duplicate membership_id values</p>";
} else {
echo "<p style='color: green; font-weight: bold;'>✓ No duplicate membership_id values (GOOD!)</p>";
}
echo "<hr>";
echo "<h2 style='color: green;'>✓✓✓ ALL CHECKS PASSED! ✓✓✓</h2>";
echo "<p style='font-size: 18px;'><strong>You can now add members without errors!</strong></p>";
echo "<div style='margin: 30px 0;'>";
echo "<a href='modules/membership/add.php' style='padding: 15px 30px; background: linear-gradient(135deg, #1E40AF 0%, #9333EA 100%); color: white; text-decoration: none; border-radius: 5px; display: inline-block; font-size: 16px; font-weight: bold;'>→ Go to Add Member Page</a>";
echo "</div>";
echo "<hr>";
echo "<h3>Summary of what was fixed:</h3>";
echo "<ul>";
echo "<li>✓ Removed UNIQUE constraint on 'membership_id' (via 'member_id' index)</li>";
echo "<li>✓ Generated unique membership_id values for empty entries</li>";
echo "<li>✓ Members can now have empty membership_id without constraint violation</li>";
echo "<li>✓ The error 'Duplicate entry '' for key 'member_id'' is resolved</li>";
echo "</ul>";
echo "<hr>";
echo "<p><small>Current indexes on members table:</small></p>";
$stmt = $db->query("SHOW INDEX FROM members");
$indexes = $stmt->fetchAll(PDO::FETCH_ASSOC);
echo "<table border='1' cellpadding='5' style='font-size: 12px;'>";
echo "<tr><th>Key Name</th><th>Column</th><th>Unique?</th></tr>";
foreach ($indexes as $index) {
$isUnique = $index['Non_unique'] == 0 ? 'YES' : 'No';
echo "<tr>";
echo "<td>{$index['Key_name']}</td>";
echo "<td>{$index['Column_name']}</td>";
echo "<td>$isUnique</td>";
echo "</tr>";
}
echo "</table>";
?>
<style>
body {
font-family: Arial, sans-serif;
max-width: 900px;
margin: 20px auto;
padding: 20px;
background: #f5f5f5;
}
h2 { color: #1E40AF; }
h3 { color: #333; margin-top: 20px; }
table { background: white; width: 100%; border-collapse: collapse; margin-top: 10px; }
th { background: #1E40AF; color: white; padding: 8px; }
td { padding: 6px; }
ul { background: white; padding: 20px; border-radius: 5px; }
li { margin: 8px 0; }
</style>
Sindbad File Manager Version 1.0, Coded By Sindbad EG ~ The Terrorists