TalkPHP
 
 
Account Login
Latest Articles
» The basic usage of PHPTAL, a XML/XHTML template library for PHP
» Vulnerable methods and the areas they are commonly trusted in.
» Simple way to protect a form from bot
» The Basics On: How Session Stealing Works
» How to keep your forms from double posting data
IRC Channel
IRC Speech Bubble Join the friendly bunch on IRC...
(#TalkPHP on Freenode)

...Also available via a web interface.

See this thread for information on the TalkPHP Free Hugs Initiative™. Subject to availability.
Associates
Associates
CSS Tutorials
Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old 07-02-2010, 12:08 PM   #1 (permalink)
The Wanderer
 
Join Date: Oct 2009
Posts: 6
Thanks: 1
rix1505 is on a distinguished road
Default Not allowing a user to book if they have two bookings that day already

Hi folks!

OK I have got on pretty well with little php / mysql project for a Water Ski Tow booking system

I'm nearly done, just one thing I'm puzzled with.

Members can log in and look at a list of ski two booking slots, and book a slot that is available. What I want to do, is once a member has booked two slots that day, is prevent them from booking anymore.

So, my database table is called bookings and it contains

ID (primary key, auto increment)
skidate (date of the slot, e.g. 03 July 2010)
skitime (time of the slot e.g. 09:10)
status (available, booked, or blocked)
member_ID (the username of the person if it's booked)

Do I check the table when a user tries to book a third slot that day, using some method in my insert script, or do I somehow not list records for days where a member has already booked 2 slots, and how would I do either of these?

Thanks in advance!

Rich :)
rix1505 is offline  
Reply With Quote
Old 07-21-2010, 09:32 PM   #2 (permalink)
The Contributor
 
dschreck's Avatar
 
Join Date: Nov 2007
Location: California
Posts: 82
Thanks: 0
dschreck is on a distinguished road
Default

Since you're limiting them to two entries, you're going to need some application side logic to control that.

This could be pretty simple to integrate into the user flow if you have a specific page that they need to hit when registering a reservation.

For example:

PHP Code:

$sql 
"SELECT 1 WHERE member_ID = {$memberID}";
$res mysql_query($sql);
$numRows mysql_num_rows($res);

if(
$numRows 2)
{
   
// they can add a new one
}
else
{
 
// they can't 

Also note that you'll need a cron or script that will automagically clean up the table to remove all their past reservations. Or, you'd need a date where clause on the query.
__________________
Where I Ramble: http://www.iwilldomybest.com/
What I do: Zynga Game Network
Senior Software Engineer at CityVille
dschreck is offline  
Reply With Quote
Reply



Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Similar Threads
Thread Thread Starter Forum Replies Last Post
Easy to Modify Login Script with Hierarchical User Permissions and XML Account File Wildhoney Script Giveaway 4 05-04-2011 06:11 AM
Automatic User Removal Seraskier Advanced PHP Programming 8 03-24-2009 08:39 AM
Zend Acl on individual user? kokjj87 Advanced PHP Programming 0 02-13-2009 03:19 PM
User profile page h0ly lag General 2 05-08-2008 08:53 PM
Calculate user ranking oMIKEo Advanced PHP Programming 3 02-29-2008 03:18 PM


All times are GMT. The time now is 01:25 PM.

 
     

Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.1.0
Inactive Reminders By Icora Web Design