Download Code for a PHP and JavaScript-Based Raffle Draw System
Raffle Draw System Using PHP and JavaScript – Source Code
Introduction
The Raffle Draw System is a simple web-based application developed using PHP and JavaScript
How Does the Raffle Draw System Work?
This system is designed for organizations or event managers to run an automated raffle draw
- Users or event staff first enter the list of tickets into the system.
- Tickets can be edited or deleted if needed.
- The system randomly selects a winner, displaying the draw process in a simple slider animation.
- The winner’s details appear in a pop-up window after the draw is completed.
Technologies Used
Database:
- MySQL (MariaDB v10.4.24)
Front-end:
- HTML
- CSS
- JavaScript
- jQuery
- Ajax
- Bootstrap
Back-end:
- PHP
Features and Functionalities
- Create New Ticket – Add new raffle tickets.
- Edit Ticket – Modify ticket details.
- Delete Ticket – Remove tickets from the list.
- List Tickets – View all added tickets.
- Random Winner Selection – Automatically pick a winner.
- Winner Inclusion/Exclusion Switch – Option to include or exclude previous winners.
- List Winners – View the history of selected winners.
Purpose of This Project
This raffle draw system is mainly developed for educational purposes. It serves as a reference for IT and Computer Science students or beginner programmers who want to learn how to build a similar application using PHP, JavaScript, and other web technologies.
How to Install and Run the System
Requirements:
- Download and install a local web server like XAMPP.
- Download the source code zip file.
Installation Steps:
- Open XAMPP Control Panel and start Apache and MySQL.
- Extract the downloaded zip file.
- Copy the extracted folder and paste it into the “htdocs” directory of XAMPP.
- Open a browser and go to PHPMyAdmin (http://localhost/phpmyadmin).
- Create a new database named
raffle_db
. - Import the provided SQL file (raffle_db.sql) from the root folder.
- Open a browser and run the system using the URL: http://localhost/php-js-raffle-draw/.
Conclusion
That’s it! You can now test and use the Raffle Draw System. This project is a great way to learn about web development using PHP and JavaScript. Feel free to modify and improve the system to enhance your programming skills.
index PHP
1 2 3 4 5 6 7 8 9 |
<?php session_start(); ?> <?php include_once('header.php') ?> <main class="container-fluid"> <?php $page = isset($_GET['page']) ? $_GET['page'] : "draw"; include("{$page}.php"); ?> </main> <?php include_once('footer.php') ?> |
raffle_db SQL
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 |
-- phpMyAdmin SQL Dump -- version 5.1.3 -- https://www.phpmyadmin.net/ -- -- Host: 127.0.0.1 -- Generation Time: Dec 12, 2022 at 07:02 AM -- Server version: 10.4.24-MariaDB -- PHP Version: 8.1.5 SET SQL_MODE = "NO_AUTO_VALUE_ON_ZERO"; START TRANSACTION; SET time_zone = "+00:00"; -- -- Database: `raffle_db` -- -- -------------------------------------------------------- -- -- Table structure for table `tickets` -- CREATE TABLE `tickets` ( `id` int(11) NOT NULL, `code` varchar(50) NOT NULL, `name` text NOT NULL ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4; -- -- Dumping data for table `tickets` -- INSERT INTO `tickets` (`id`, `code`, `name`) VALUES (2, '6231415', 'Mark Cooper'), (4, 'WUB93NWW8FG', 'Colton Parsons'), (5, 'QEJ41PMK1PX', 'Cara Lynn'), (6, 'SSB06QKY5VF', 'Cameron Black'), (7, 'URE38IYJ2MT', 'Charissa Anderson'), (8, 'ERI25DQE5RJ', 'Donovan Walters'), (9, 'LSF46XXX8HK', 'Angela Vinson'), (10, 'SSN55RSP2DH', 'Acton Rosales'), (11, 'NSI93DGR7TL', 'Harding Russo'), (12, 'CXO32TMQ5PG', 'Norman Lewis'), (13, 'MTK93IJJ8ZL', 'Jolie Rodriquez'), (14, 'RRK60JER7LV', 'Joel Mercer'), (15, 'FPY19DMI5BL', 'Ariel Jacobson'), (16, 'EWI37NKV7TS', 'Jonah Jarvis'), (17, 'CNN41HOV6WE', 'Macaulay Byrd'), (18, 'KAA41ZHZ1MD', 'Marah Knowles'); -- -------------------------------------------------------- -- -- Table structure for table `winners` -- CREATE TABLE `winners` ( `id` int(11) NOT NULL, `ticket_id` int(11) NOT NULL, `draw` int(10) NOT NULL ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4; -- -- Dumping data for table `winners` -- INSERT INTO `winners` (`id`, `ticket_id`, `draw`) VALUES (1, 7, 1), (3, 5, 2), (4, 5, 3), (5, 16, 4), (6, 14, 5), (7, 15, 6), (8, 9, 7); -- -- Indexes for dumped tables -- -- -- Indexes for table `tickets` -- ALTER TABLE `tickets` ADD PRIMARY KEY (`id`); -- -- Indexes for table `winners` -- ALTER TABLE `winners` ADD PRIMARY KEY (`id`), ADD KEY `ticket_id_fk` (`ticket_id`); -- -- AUTO_INCREMENT for dumped tables -- -- -- AUTO_INCREMENT for table `tickets` -- ALTER TABLE `tickets` MODIFY `id` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=19; -- -- AUTO_INCREMENT for table `winners` -- ALTER TABLE `winners` MODIFY `id` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=9; -- -- Constraints for dumped tables -- -- -- Constraints for table `winners` -- ALTER TABLE `winners` ADD CONSTRAINT `ticket_id_fk` FOREIGN KEY (`ticket_id`) REFERENCES `tickets` (`id`) ON DELETE CASCADE ON UPDATE NO ACTION; COMMIT; |