31 lines
931 B
PHP
31 lines
931 B
PHP
<?php
|
|
include('koneksi.php');
|
|
|
|
// Fungsi untuk mengecek apakah kolom ada
|
|
function column_exists($conn, $table, $column) {
|
|
$result = mysqli_query($conn, "SHOW COLUMNS FROM `$table` LIKE '$column'");
|
|
return mysqli_num_rows($result) > 0;
|
|
}
|
|
|
|
$errors = [];
|
|
|
|
// Cek dan Tambah kolom 'nama'
|
|
if (!column_exists($conn, 'users', 'nama')) {
|
|
if (!mysqli_query($conn, "ALTER TABLE users ADD COLUMN nama VARCHAR(100)")) {
|
|
$errors[] = "Gagal tambah kolom 'nama': " . mysqli_error($conn);
|
|
}
|
|
}
|
|
|
|
// Cek dan Tambah kolom 'id_rumah_ibadah'
|
|
if (!column_exists($conn, 'users', 'id_rumah_ibadah')) {
|
|
if (!mysqli_query($conn, "ALTER TABLE users ADD COLUMN id_rumah_ibadah INT(11) NULL")) {
|
|
$errors[] = "Gagal tambah kolom 'id_rumah_ibadah': " . mysqli_error($conn);
|
|
}
|
|
}
|
|
|
|
if (empty($errors)) {
|
|
echo "✅ Semua kolom sudah siap! Tidak ada error.";
|
|
} else {
|
|
foreach ($errors as $e) { echo "❌ $e <br>"; }
|
|
}
|
|
?>
|