Skip to content

Repository files navigation

Event Website

This is a small PHP + MySQL event website with a Bootstrap frontend. It includes:

  • Landing page with events carousel and admin-managed events
  • Admin authentication and event CRUD (create / update / delete)
  • Registration form that stores users and links to event registrations

This README explains how to run the project locally, import the database schema, use the admin UI, and call the API.


Prerequisites

  • Windows with XAMPP (Apache + MySQL) installed and running, or another PHP + MySQL stack.
  • A browser.
  • (Optional) MySQL Workbench or mysql CLI for importing the schema.

Quick start (local)

  1. Start XAMPP (Apache and MySQL).
  2. Import the SQL schema to create the database and tables.

Using MySQL Workbench: open c:\xampp\htdocs\sql\schema.sql and execute it.

Or from PowerShell / Command Prompt (will prompt for MySQL password):

mysql -u root -p < "C:\xampp\htdocs\sql\schema.sql"
  1. Open the site in your browser:
http://localhost/index.php
  1. Admin login page:
http://localhost/admin_login.html

Default admin credentials (for development only):

  • Username: admin
  • Password: admin123

You can change these values in php/admin_auth.php or migrate to a proper users table.


How to add an event

Admin UI (recommended)

  1. Go to http://localhost/admin_login.html and log in with admin credentials.
  2. Return to http://localhost/index.php and you should see an Add Event button in the Events section.
  3. Click Add Event, fill in the Title, Date, Description and Location, then Save.

The frontend will POST the data to php/events.php which creates the event in the events table.

API (programmatic)

You can create events by POSTing form-data to php/events.php. The endpoint expects an admin session, so either use the admin UI or perform a login first to obtain the session cookie.

Example using curl with cookie jar (PowerShell / CLI):

# 1) Login and save cookies
curl -c cookies.txt -X POST -F "action=login" -F "username=admin" -F "password=admin123" http://localhost/php/admin_auth.php

# 2) Create event using the same cookie jar
curl -b cookies.txt -X POST -F "action=create" -F "title=Networking Gala" -F "description=Evening of networking" -F "event_date=2025-06-05T19:00" -F "location=Chicago, IL" http://localhost/php/events.php

To update or delete use action=update (include id) or action=delete (include id).


How registration works

  • The registration form on the landing page (and cadastro.html) submits to php/register.php.
  • php/register.php saves user data into registrations.
  • If event_id is provided in the registration, the script also creates a row in event_registrations that links the user to the event.

To register via API you can post the form fields to php/register.php (AJAX from the site already wired up):

curl -X POST -F "name=Jane Doe" -F "email=jane@example.com" -F "event_id=1" -F "event_date=2025-06-05T19:00" http://localhost/php/register.php

Files overview

  • index.php — Landing page (Bootstrap) and events carousel
  • css/style.css — Project styles, fonts and colors
  • js/script.js — Frontend JS for events, registration, and admin modal
  • php/events.php — Events API (GET list, GET single, POST create/update/delete)
  • php/admin_auth.php — Simple admin login/logout (session-based)
  • php/register.php — Register user + optional event registration
  • php/fetch_users.php — Used by consulta.php to list registrations
  • admin_login.html — Admin login page
  • sql/schema.sql — Database schema (create DB, registrations, event_registrations)

Security notes

  • The current admin credentials are stored in php/admin_auth.php as constants for simplicity — this is NOT secure for production. Move them to a hashed password in a database or environment variable.
  • All admin POST actions in php/events.php require the session is_admin flag. If you add remote API access you should use token-based or more secure auth.
  • Input validation is minimal; consider adding server-side validation and CSRF protection.

Troubleshooting

  • If the landing page reports a missing events table, re-run sql/schema.sql or visit index.php — it will attempt to create the events table on first run (but database user needs CREATE privileges).
  • If static assets (fonts/icons) do not load, ensure your server has internet access or replace with local copies.

If you'd like, I can:

  • Convert the project to use a shared header.php and footer.php to avoid duplicated navbars,
  • Add an admin dashboard page to list and manage events,
  • Implement hashed admin users in the database,
  • Add CSRF tokens and input validation.

Tell me which of these you'd like next and I'll implement it.

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages