0% found this document useful (0 votes)
4 views8 pages

Online Event Management System

The document outlines the creation of an online event management website using HTML, CSS, and PHP, featuring user registration, event browsing, and registration functionalities. It includes a database schema for users, events, and registrations, along with the PHP code for handling user actions and displaying event information. Additionally, it provides CSS styling for the website's layout and design elements.

Uploaded by

vtu22484
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
4 views8 pages

Online Event Management System

The document outlines the creation of an online event management website using HTML, CSS, and PHP, featuring user registration, event browsing, and registration functionalities. It includes a database schema for users, events, and registrations, along with the PHP code for handling user actions and displaying event information. Additionally, it provides CSS styling for the website's layout and design elements.

Uploaded by

vtu22484
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

Build a online event management website where users can browse and register

for Upcoming events. The website should include event listings, event details
pages, user registration and login, and a registration process for users to sign up
for [Link] need to use HTML, CSS, and PHP to build the website.

[Link]

<?php
session_start();
$db = new PDO('sqlite:[Link]');
$db->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
$db->exec("PRAGMA foreign_keys = ON");
$db->exec("CREATE TABLE IF NOT EXISTS users(id INTEGER PRIMARY KEY, name TEXT,
email TEXT UNIQUE, password TEXT)");
$db->exec("CREATE TABLE IF NOT EXISTS events(id INTEGER PRIMARY KEY, title TEXT,
short TEXT, details TEXT, date TEXT, seats INTEGER)");
$db->exec("CREATE TABLE IF NOT EXISTS registrations(id INTEGER PRIMARY KEY, user_id
INTEGER, event_id INTEGER, created_at TEXT, UNIQUE(user_id,event_id), FOREIGN
KEY(user_id) REFERENCES users(id) ON DELETE CASCADE, FOREIGN KEY(event_id)
REFERENCES events(id) ON DELETE CASCADE)");
$seed = $db->query("SELECT count(*) FROM events")->fetchColumn();
if($seed==0){
$db->prepare("INSERT INTO events(title,short,details,date,seats) VALUES(?,?,?,?,?)")
->execute(['Intro to Web Dev','Learn basics of HTML/CSS/PHP','A hands-on workshop covering
frontend and backend basics','2025-11-10 10:00',50]);
$db->prepare("INSERT INTO events(title,short,details,date,seats) VALUES(?,?,?,?,?)")
->execute(['AI & Ethics','Discussion on AI ethics','Panel and Q&A with experts','2025-12-05
14:00',30]);
$db->prepare("INSERT INTO events(title,short,details,date,seats) VALUES(?,?,?,?,?)")
->execute(['HackNight','Collaborative coding night','Build small projects & network','2025-11-25
18:00',100]);
}
function current_user(){ return isset($_SESSION['user'])?$_SESSION['user']:null; }
$u = current_user();
$err = '';
if($_SERVER['REQUEST_METHOD']==='POST'){
if(isset($_POST['register_user'])){
$n=trim($_POST['name']); $e=trim($_POST['email']); $p=$_POST['password'];
if(!$n||!$e||!$p){ $err='Fill all fields.'; } else {
$h=password_hash($p,PASSWORD_DEFAULT);
$s = $GLOBALS['db']->prepare("INSERT INTO users(name,email,password) VALUES(?,?,?)");
try{ $s->execute([$n,$e,$h]); $_SESSION['user']=['id'=>$GLOBALS['db']-
>lastInsertId(),'name'=>$n,'email'=>$e]; header('Location: [Link]'); exit; }
catch(Exception $ex){ $err='Email already used.'; }
}
}
if(isset($_POST['login_user'])){
$e=trim($_POST['email']); $p=$_POST['password'];
$s=$db->prepare("SELECT * FROM users WHERE email=?"); $s->execute([$e]); $user=$s-
>fetch(PDO::FETCH_ASSOC);
if($user && password_verify($p,$user['password'])){
$_SESSION['user']=['id'=>$user['id'],'name'=>$user['name'],'email'=>$user['email']];
header('Location: [Link]'); exit; } else $err='Invalid credentials.';
}
if(isset($_POST['signup_event']) && $u){
$eid=(int)$_POST['event_id'];
$s=$db->prepare("SELECT seats FROM events WHERE id=?"); $s->execute([$eid]); $ev=$s-
>fetch(PDO::FETCH_ASSOC);
if(!$ev) $err='Event not found.'; else {
$count=$db->prepare("SELECT count(*) FROM registrations WHERE event_id=?")-
>execute([$eid]);
$taken = $db->query("SELECT count(*) FROM registrations WHERE event_id={$eid}")-
>fetchColumn();
if($taken >= $ev['seats']) $err='No seats available.'; else {
try{
$ins=$db->prepare("INSERT INTO registrations(user_id,event_id,created_at)
VALUES(?,?,?)");
$ins->execute([$u['id'],$eid,date('c')]);
header('Location: [Link]?page=dashboard'); exit;
}catch(Exception $ex){ $err='Already registered.'; }
}
}
}
}
if(isset($_GET['action']) && $_GET['action']=='logout'){ session_destroy(); header('Location:
[Link]'); exit; }
$page = $_GET['page'] ?? 'home';
?>
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8"/><meta name="viewport" content="width=device-width,initial-
scale=1"/><title>EventManager</title>
<link rel="stylesheet" href="[Link]">
</head>
<body>
<header>
<a class="logo" href="[Link]">EventManager</a>
<nav>
<a href="[Link]">Events</a>
<?php if(!$u): ?>
<a href="[Link]?page=login">Login</a>
<a href="[Link]?page=register">Sign up</a>
<?php else: ?>
<a href="[Link]?page=dashboard">My Registrations</a>
<span class="hi">Hi, <?=htmlspecialchars($u['name'])?></span>
<a href="[Link]?action=logout">Logout</a>
<?php endif;?>
</nav>
</header>
<main>
<?php if($err): ?><div class="error"><?=$err?></div><?php endif; ?>

<?php if($page==='home'): ?>


<section class="list">
<?php $rows = $db->query("SELECT * FROM events ORDER BY date ASC")-
>fetchAll(PDO::FETCH_ASSOC);
foreach($rows as $e): ?>
<article class="card">
<h3><?=htmlspecialchars($e['title'])?></h3>
<p class="short"><?=htmlspecialchars($e['short'])?></p>
<div class="meta"><?=date('M j, Y, H:i',strtotime($e['date']))?> · Seats: <?=$e['seats']?></div>
<div class="actions">
<a href="[Link]?page=event&id=<?=$e['id']?>">Details</a>
</div>
</article>
<?php endforeach; ?>
</section>

<?php elseif($page==='event' && isset($_GET['id'])):


$id=(int)$_GET['id'];
$s=$db->prepare("SELECT * FROM events WHERE id=?"); $s->execute([$id]); $ev=$s-
>fetch(PDO::FETCH_ASSOC);
if(!$ev){ echo "<p>Event not found.</p>"; }
else:
$regCount = $db->prepare("SELECT count(*) FROM registrations WHERE event_id=?");
$regCount->execute([$id]); $taken = $regCount->fetchColumn();
?>
<article class="detail">
<h2><?=htmlspecialchars($ev['title'])?></h2>
<div class="meta"><?=date('F j, Y, H:i',strtotime($ev['date']))?> · Seats <?=$ev['seats']?> ·
Registered <?=$taken?></div>
<p><?=nl2br(htmlspecialchars($ev['details']))?></p>
<?php if(!$u): ?>
<p><a href="[Link]?page=login">Login</a> to register for this event.</p>
<?php else: ?>
<form method="post" class="inline">
<input type="hidden" name="event_id" value="<?=$ev['id']?>">
<button type="submit" name="signup_event">Register</button>
</form>
<?php endif; ?>
</article>
<?php endif; ?>

<?php if($page==='register'): ?>


<form class="form" method="post">
<h2>Create account</h2>
<input name="name" placeholder="Full name" required>
<input name="email" placeholder="Email" type="email" required>
<input name="password" placeholder="Password" type="password" required>
<button name="register_user" type="submit">Register</button>
</form>
<?php endif; ?>

<?php if($page==='login'): ?>


<form class="form" method="post">
<h2>Login</h2>
<input name="email" placeholder="Email" type="email" required>
<input name="password" placeholder="Password" type="password" required>
<button name="login_user" type="submit">Login</button>
</form>
<?php endif; ?>

<?php if($page==='dashboard' && $u):


$s=$db->prepare("SELECT r.created_at,e.* FROM registrations r JOIN events e ON [Link]=r.event_id
WHERE r.user_id=? ORDER BY [Link] ASC");
$s->execute([$u['id']]); $regs = $s->fetchAll(PDO::FETCH_ASSOC);
?>
<section class="dashboard">
<h2>My Registrations</h2>
<?php if(!$regs): ?><p>No registrations yet.</p><?php endif;?>
<?php foreach($regs as $r): ?>
<div class="reg">
<h4><?=htmlspecialchars($r['title'])?></h4>
<div class="meta"><?=date('F j, Y, H:i',strtotime($r['date']))?> · Registered <?=date('M j,
Y',strtotime($r['created_at']))?></div>
<a href="[Link]?page=event&id=<?=$r['id']?>">View</a>
</div>
<?php endforeach; ?>
</section>
<?php endif; ?>

</main>
<footer>
<small>&copy; <?=date('Y')?> EventManager</small>
</footer>
</body>
</html>

[Link]

*{
box-sizing: border-box;
margin: 0;
padding: 0
}

:root {
--bg: #0f1724;
--card: #0b1220;
--accent: #60a5fa;
--muted: #94a3b8
}

html,
body {
height: 100%;
font-family: Inter, system-ui, Segoe UI, Roboto, Arial;
background: linear-gradient(180deg, #071029, #071627);
color: #e6eef6
}

header {
display: flex;
justify-content: space-between;
align-items: center;
padding: 16px 24px;
background: rgba(255, 255, 255, 0.02)
}

.logo {
font-weight: 700;
color: var(--accent);
text-decoration: none
}

nav a {
color: var(--muted);
margin-left: 12px;
text-decoration: none
}

nav .hi {
margin-left: 12px;
color: #cfe6ff
}

main {
max-width: 980px;
margin: 28px auto;
padding: 20px
}

.list {
display: grid;
grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
gap: 16px
}

.card {
background: linear-gradient(180deg, rgba(255, 255, 255, 0.02), transparent);
padding: 16px;
border-radius: 10px;
box-shadow: 0 6px 18px rgba(2, 6, 23, 0.6)
}

.card h3 {
margin-bottom: 8px
}

.short {
color: var(--muted);
margin-bottom: 12px
}

.meta {
font-size: 13px;
color: var(--muted);
margin-bottom: 8px
}
.actions a,
.card .actions button {
background: none;
border: 1px solid rgba(255, 255, 255, 0.06);
padding: 8px 10px;
border-radius: 8px;
color: var(--accent);
text-decoration: none
}

.detail {
background: linear-gradient(180deg, rgba(255, 255, 255, 0.02), transparent);
padding: 20px;
border-radius: 10px
}

.form {
max-width: 420px;
margin: 0 auto;
display: flex;
flex-direction: column;
gap: 12px;
background: rgba(255, 255, 255, 0.02);
padding: 20px;
border-radius: 10px
}

.form input {
padding: 10px;
border-radius: 8px;
border: 1px solid rgba(255, 255, 255, 0.04);
background: transparent;
color: inherit
}

.form button,
.inline button {
padding: 10px 14px;
border-radius: 8px;
border: none;
background: var(--accent);
color: #04203a;
cursor: pointer
}

.inline {
display: inline-block;
margin-top: 12px
}

.error {
max-width: 980px;
margin: 12px auto;
padding: 10px;
background: #3a0b0b;
color: #ffdede;
border-radius: 8px
}

.dashboard .reg {
background: rgba(255, 255, 255, 0.02);
padding: 12px;
border-radius: 8px;
margin-bottom: 10px;
display: flex;
justify-content: space-between;
align-items: center
}

footer {
text-align: center;
padding: 18px;
color: var(--muted)
}

@media(max-width:600px) {
header {
flex-direction: column;
align-items: flex-start
}

nav {
margin-top: 8px
}
}

You might also like