<?php
// Include database configuration
require_once 'database/db_config.php';
// Display header
echo "<!DOCTYPE html>
<html>
<head>
<title>Add Profile Image Column</title>
<style>
body { font-family: Arial, sans-serif; line-height: 1.6; margin: 20px; }
h1 { color: #333; }
.success { color: green; }
.error { color: red; }
.info { color: blue; }
</style>
</head>
<body>
<h1>Adding Profile Image Column to Users Table</h1>";
try {
// Check if the users table exists
$table_exists = $conn->query("SHOW TABLES LIKE 'users'");
if ($table_exists->num_rows == 0) {
throw new Exception("Users table does not exist!");
}
// Add profile_image column if it doesn't exist
$column_exists = $conn->query("SHOW COLUMNS FROM users LIKE 'profile_image'");
if ($column_exists->num_rows == 0) {
if ($conn->query("ALTER TABLE users ADD COLUMN profile_image VARCHAR(255) DEFAULT NULL")) {
echo "<p class='success'>✅ Added profile_image column to users table.</p>";
} else {
throw new Exception("Failed to add profile_image column: " . $conn->error);
}
} else {
echo "<p class='info'>ℹ️ profile_image column already exists.</p>";
}
echo "<p class='success'>✅ Users table structure has been updated successfully.</p>";
echo "<p>Return to <a href='index.php'>Admin Dashboard</a></p>";
} catch (Exception $e) {
echo "<p class='error'>❌ Error: " . $e->getMessage() . "</p>";
echo "<p>Return to <a href='index.php'>Admin Dashboard</a></p>";
}
echo "</body></html>";
?>