cspgsl Posted March 31, 2010 Share Posted March 31, 2010 I have found a php script that allows a user to download a file and then prevent further downloads for a set amount of time. You can find it here http://www.web-development-blog.com/archives/limit-the-number-of-downloads-per-client/ As I am not very strong in coding, I am hoping with some assistance to modify the concept so that it will not allow a registered user to print a coupon I offer more than once. The process would work as such: the user registers (I am developing in Joomla using the Community Builder login / member component) the user clicks a link in the activation email welcome page opens with a link to the coupon user clicks the coupon link the link opens a page with the coupon and a print button in the same window to get around a popup blocker user clicks the print button and the page prints out the coupon print button also advances the page to a thank you page if the user clicks on the back button to access the link again the script prevents the user from opening the coupon window again with the message that there is only one coupon per user) I am assuming that this is doable but don't mind being told otherwise. I would be very grateful if there are any coders out there that could assist. Thanks Quote Link to comment https://forums.phpfreaks.com/topic/197139-script-to-limit-printing-of-a-coupon-to-once-per-user/ Share on other sites More sharing options...
Jax2 Posted March 31, 2010 Share Posted March 31, 2010 Couldn't you simply make a new table that has these rows: userID viewed and then set it up so that when they view the page, it updates that table to set viewed as 1 for that user ID. Set up the coupon page to first check if the user name has visited the page before, if it = 0, show the page, if 1, don't show the coupon. If they have viewed the page, include a meta refresh that takes them to a new page instantly, so they can't go back to see it again Know what I mean? Quote Link to comment https://forums.phpfreaks.com/topic/197139-script-to-limit-printing-of-a-coupon-to-once-per-user/#findComment-1034823 Share on other sites More sharing options...
jcbones Posted March 31, 2010 Share Posted March 31, 2010 I would put an insert query on the thank you page. This would be on a table called printed_coupons. 2 fields, coupon_id and user. $sql = "INSERT INTO `printed_coupons`(`coupon_id`,`user`) VALUES ('$id','$user')"; mysql_query($sql); at the top of the print page, I would put this. <?php $sql = "SELECT `coupon_id` FROM `printed_coupons` WHERE `coupon_id` = '$coupon_id' AND `user` = '$user'"; $result = mysql_query($sql); if(mysql_num_rows($result) > 0) { die('You have already printed this coupon'); } ?> Quote Link to comment https://forums.phpfreaks.com/topic/197139-script-to-limit-printing-of-a-coupon-to-once-per-user/#findComment-1034950 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.