Page 1 of 1

Booking System in PHP

Posted: Mon Oct 10, 2005 12:40 pm
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 :-)

Posted: Mon Oct 10, 2005 1:49 pm
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().

Time in PHP - Booking System

Posted: Mon Oct 10, 2005 2:15 pm
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

Posted: Mon Oct 10, 2005 2:52 pm
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"))."'";

Query

Posted: Tue Oct 11, 2005 9:13 am
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

Posted: Tue Oct 11, 2005 9:16 am
by feyd
you didn't supply a valid link identifier or supplied an invalid one. Check your mysql_connect() details.

Posted: Tue Oct 11, 2005 11:38 am
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

Posted: Tue Oct 11, 2005 12:08 pm
by feyd
posting code is a start.