Project Idea | Anonymous Message Prank Game in PHP
In this article, we are going to learn concepts of database, how to make a simple game using PHP and MySQL, how can we implement a database in which we send secret messages for a particular user, how to arrange tables in the database and Also we learn some security issues that how can we save our web apps from these security issues.
Domain: Web application using PHP and MySQL database.
- Sign Up
- Secret Messages to a particular user by using a URL provided by Sign up user
- Sending messages by Ajax Requests
It is a simple game in which users send secret messages for a particular user by using a link. Through this game we learn a lot of things like how to sign up and login to a user by creating a session and destroying session, How can we store data of users and secret messages in the database for a particular user who has created a link for his name.
Tools and Technologies:
- BOOTSTRAP CDN
- HTML and CSS
- Database – MySQL
- XAMP Server ( for creating server on Localhost )
Project Implementation: Make an empty Folder and create files According to this File structure
Assets folder: First, let us start from the assets folder. So we create this folder because of assets that we use in a project like images, videos, global CSS, and js file which is attached to all files in our project. we also create an index.php file for all folders because if someone is trying to access this folder then he sees only an index page not our directory
if index.php file is not created then anyone can see our file structure of the whole project
Utils Folder – make filename as protectXss.php – This file is Basically used to protect our web App from Cross-Site Scripting attacks.
Partials Folder and make files according to file structure as shown:
Inside the partials folder make a folder named as modals to place all modals in it
Root Folder: Make files according to this structure.
Filename – index.php
Create index.php which is the main page of the web app. In this page, we are creating a form that takes the name of the user as input to start the game.
File name – welcome.php
We are creating this file for seeing messages that are come from other users and providing username and password to the signup user. Along with the username and password a link is also provided so that the signup user shares it with others and others send him anonymous messages.
Filename – anonymous.php
We are creating this file for URL which we provided to our sign up users so that they share that URL with their friends and directing friends to this file using that URL
Filename – logout.php
To logout users and destroying sessions.
Database: Start XAMP Server
Go to browser and type 127.0.0.1 in the addressbar
Go to phpmyadmin and create a new database named as “anonymousdb”
Make tables according to this below structures shown
Table name – “an_users”
To make a column unique click on “more” near “drop” and select “unique”