Booking System in PHP

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
pbaker
Forum Newbie
Posts: 4
Joined: Mon Oct 10, 2005 12:32 pm

Booking System in PHP

Post by pbaker »

I am creating a booking system and have done the form and created all the fields in a SQL database, im only a beginner @ PHP so need some help but basically once the forms been filled out i want it to submit the details to the database which i can get it to do. the thing im getting stuck on is either using a function or array or if statement so where by if that same form gets filled out again it checks to see if the time thats been entered is the same as one already there or within 1hr of that time if so then to return an error just underneath that box saying sorry time already taken please choose another.

Also so that the form will only submit so many entrys per day and to then also be able to click on a button so it input entrys for a specfic day into a PDF template.

hope someone can help :-)
User avatar
Burrito
Spockulator
Posts: 4715
Joined: Wed Feb 04, 2004 8:15 pm
Location: Eden, Utah

Post by Burrito »

it depends on how your fields are set up on your table:

if they are set up as datetime or just time fields, you can query off of the db and determine if the NOW is between the time inserted and one hour after by formatting the data/time with date():

if they are set up as a strings with a time() stamp, you can just determine if the time is between NOW and one hour before by just using the unix time with time().
pbaker
Forum Newbie
Posts: 4
Joined: Mon Oct 10, 2005 12:32 pm

Time in PHP - Booking System

Post by pbaker »

i have changed one of the fields to a timestamp field now what do i have 2 do to my code and how can i set it up one hour before or after like u explained above.

how will it now if its an hour before or after and to display and error message if that times already been taken
User avatar
Burrito
Spockulator
Posts: 4715
Joined: Wed Feb 04, 2004 8:15 pm
Location: Eden, Utah

Post by Burrito »

I can't say I've ever used a timestamp field so I'm not sure what format that data will be in.

but regardless you just need to build a query to look for a time block that fits within your time in question and if a row exists, then you can't use it:

ex:

Code: Select all

$insertime = "9:00 am";
$query = "select * from myTable where time between '".date("G:i",strtotime($inserttime))."' and '".date("G:i",strtotime($inserttime." +1 hour"))."'";
pbaker
Forum Newbie
Posts: 4
Joined: Mon Oct 10, 2005 12:32 pm

Query

Post by pbaker »

i have tried to query the database but every time i go to load the page up i get it saying saying this : Warning: mysql_query(): supplied resource is not a valid MySQL-Link resource in PATHNAME in to lines but the trouble is the name for the table in the database is correct so what else could be causing this
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

you didn't supply a valid link identifier or supplied an invalid one. Check your mysql_connect() details.
pbaker
Forum Newbie
Posts: 4
Joined: Mon Oct 10, 2005 12:32 pm

Post by pbaker »

You say that but i done this via a record set in dreamweaver and as soon as i remove it the form works fine so what could be wrong
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

posting code is a start.
Post Reply