![]() 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/private_html/ |
<?php
session_start();
require_once 'config/database.php';
// Only allow admin to run this
if (!isset($_SESSION['user_id']) || !isset($_SESSION['is_admin']) || !$_SESSION['is_admin']) {
die('Access denied. Admin only.');
}
$pdo = getDBConnection();
echo "<h1>🎫 Creating Event Tickets Database Table</h1>";
try {
// Event tickets table
$pdo->exec("
CREATE TABLE IF NOT EXISTS event_tickets (
id INT AUTO_INCREMENT PRIMARY KEY,
event_id INT NOT NULL,
user_id INT NOT NULL,
ticket_code VARCHAR(50) UNIQUE NOT NULL,
qr_code_data TEXT,
price_paid DECIMAL(10, 2) NOT NULL,
payment_method VARCHAR(50) DEFAULT 'stripe',
stripe_payment_intent_id VARCHAR(255),
status ENUM('pending', 'confirmed', 'used', 'cancelled') DEFAULT 'pending',
checked_in_at DATETIME NULL,
checked_in_by INT NULL,
purchase_date TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
FOREIGN KEY (event_id) REFERENCES events(id) ON DELETE CASCADE,
FOREIGN KEY (user_id) REFERENCES users(id) ON DELETE CASCADE,
FOREIGN KEY (checked_in_by) REFERENCES users(id) ON DELETE SET NULL,
INDEX idx_ticket_code (ticket_code),
INDEX idx_event_user (event_id, user_id),
INDEX idx_status (status)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4
");
echo "<p>✅ Created event_tickets table</p>";
// Event ticket sales table (for revenue tracking)
$pdo->exec("
CREATE TABLE IF NOT EXISTS event_ticket_sales (
id INT AUTO_INCREMENT PRIMARY KEY,
ticket_id INT NOT NULL,
event_id INT NOT NULL,
buyer_id INT NOT NULL,
event_creator_id INT NOT NULL,
amount DECIMAL(10, 2) NOT NULL,
revenue_recipient VARCHAR(20) DEFAULT 'event_creator',
recipient_id INT,
created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
FOREIGN KEY (ticket_id) REFERENCES event_tickets(id) ON DELETE CASCADE,
FOREIGN KEY (event_id) REFERENCES events(id) ON DELETE CASCADE,
FOREIGN KEY (buyer_id) REFERENCES users(id) ON DELETE CASCADE,
FOREIGN KEY (event_creator_id) REFERENCES users(id) ON DELETE CASCADE,
INDEX idx_event_creator (event_creator_id),
INDEX idx_created_at (created_at)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4
");
echo "<p>✅ Created event_ticket_sales table</p>";
echo "<h2>✅ All tables created successfully!</h2>";
} catch (PDOException $e) {
echo "<p>❌ Error: " . $e->getMessage() . "</p>";
}
?>