Simple PHP Reservations system

Hi,

I have been tasked to create a php reservations system for a game rental system. The system needs to be as simple as it can be in order to understand it.

The problem is that I have no idea where to even start. The requirements of my system are as follows:

[ul][li]The reservations web page should have a form where pupils can fill in the following details:
• their name
• game ID (possible drop down field, populated from my database table??)
• start date of the reservation
• number of days the game will be reserved (this must be a number between 1 and 5).
[/li][/ul]

MY THOUGHTS: I’m guessing what I need to do here is have some simple form validation on my fields to ensure that the number of days is between 1 and 5.

[ul][li]The system should check that the game ID entered into the form is valid and then display
the name of the game on the page. The game ID is valid if it matches one of the game IDs
listed in the database table called games.
[/li][/ul]

MY THOUGHTS: So the code from 1(above) should be edited so that when a user selects a gameID that would possibly be a drop down field which is populated from the database table and then display the game that has been selected on screen.

[ul][li][b]
The system should check that the game is available for the requested dates of reservation.

If the reservation is for more than one day then all relevant dates need to be checked for
availability. For example, if the start date of the reservation is 21st January 2016 and the
number of days the game will be reserved is 3 then the dates 21st January 2016, 22nd
January 2016 and 23rd January 2016 should be checked for availability.

If the game is not available for one or more of the days requested then an appropriate error
message should be displayed.
[/b][/li][/ul]

MY THOUGHTS: This is where i’m lost… would I have to put some conditions in the system that would show that an individual game cannot be selected on dates that it has been reserved??? Would this form part of my games table in my database???

[ul][li]
The system should calculate and display how much the pupil must pay to rent the game.
To work this out the number of days of the reservation is multiplied by the game’s rental
cost per day.
[/li][/ul]

MY THOUGHTS: I’m guessing that depending on the value entered into the number of days field, I would be mutiplying that by the price of the game rental and then display back a total??

[ul][li]
The reservation details should be saved, providing they are all valid.
[/li][/ul]

MY THOUGHTS: Hmmm this would just be a simply insert statement that would alter the database. Am I write in saying that I would need 3 tables in my database?? customer, games and reservations???

Anyones help would be much appreciated?? thanks for reading.
[/list]

If you have the requirements you can just start with something. You can implement functionality as you go. You could start with creating the games table in the db and listing all games on a page. then add stuff from there.

would make sense, remember that all validations done client side are for user experience only. business rules and security should be enforced by server side validation.

ie: list_games.php shows a list of all games, each game has a link to game.php?id=game_id_here that shows info about a single game

yes, you should build some sort of calendar that has available / not available for each day so its easy for the user to see when he can rent the game

It could, a much better db structure would be to have one user table, one game table, and one game_reservation table.

game_reservation table could be
game_id, user_id, from_date, to_date

Yup

that would be best, this way you could also track/display rental statistics/etc.

Hi,

Thanks for the response. Although i’m confused by the following:

My way of seeing this page from the specification is that when you select a gameID from a populated drop down box the selected game would appear below the form after the submit button is pressed… is that possible or does it go to a new page presumably called list_games.php??

Thanks

MadScientist

Ah, mis-read that. as far as I can see the reservation-form only need these fields

their name
if you have a login system then this can be added automagically

game id
drop down field showing game name (and cover)

date from
datepicker? comes standard with twitter bootstrap/etc

number of days
would have this as a drop down as well with values 1-5

Sponsor our Newsletter | Privacy Policy | Terms of Service