big-dog1965 Posted September 10, 2009 Share Posted September 10, 2009 I didnt really see where to post this so....... Is there some way I can make a page or popup only appear for a visitor one time over like a year period of time What Im looking to do is have a coupon for a free race entry a visitor can print off and use, but only have that option once per visitor. Quote Link to comment https://forums.phpfreaks.com/topic/173822-one-time-popup-for-visitors/ Share on other sites More sharing options...
sh0wtym3 Posted September 10, 2009 Share Posted September 10, 2009 That might be easy or difficult to do, depending on your situation. Solution #1 If your visitors are "members" of your site (i.e. do they have to log in first to get the coupon), you can easily track who received a coupon and who didn't within the last year. Let me know if this is the case. Solution #2 You can track this using cookies. DRAWBACK - most people clear their cookies on a monthly basis so the cookie you added would soon disappear. Solution #3 You can track visitors by their IP address using PHP, then block that IP from receiving another coupon until a year lapses. DRAWBACK - That visitor could get more coupons by simply visiting your site from another computer. Or if that visitor is using a public computer (at a library maybe) then you just blocked anyone else who uses that computer from receiving the coupon. Quote Link to comment https://forums.phpfreaks.com/topic/173822-one-time-popup-for-visitors/#findComment-916257 Share on other sites More sharing options...
mikesta707 Posted September 10, 2009 Share Posted September 10, 2009 people with dynamic IP's will run into problems because they will be prompted to get another coupon. This also won't work with people who clear their cookies or have them disabled. Also if you use cookies people can easily alter the cookies. Using a member system to decide will be the best way in my opinion. Quote Link to comment https://forums.phpfreaks.com/topic/173822-one-time-popup-for-visitors/#findComment-916260 Share on other sites More sharing options...
big-dog1965 Posted September 10, 2009 Author Share Posted September 10, 2009 I do have phpbb installed so theres my login, but I have no idea how to make the coupon thing work help would be great on the script or what ever thanks Quote Link to comment https://forums.phpfreaks.com/topic/173822-one-time-popup-for-visitors/#findComment-916382 Share on other sites More sharing options...
l0ve2hat3 Posted September 11, 2009 Share Posted September 11, 2009 create a table called `coupon` or what ever fields: id,user_id,coupon,date check the table when the user goes to the coupon page to see if that session user already downloaded the coupon. if not insert the record into the table and give them the coupon Quote Link to comment https://forums.phpfreaks.com/topic/173822-one-time-popup-for-visitors/#findComment-916430 Share on other sites More sharing options...
big-dog1965 Posted September 11, 2009 Author Share Posted September 11, 2009 I can creat the table and fields, but dont know how to do the rest Quote Link to comment https://forums.phpfreaks.com/topic/173822-one-time-popup-for-visitors/#findComment-916450 Share on other sites More sharing options...
l0ve2hat3 Posted September 11, 2009 Share Posted September 11, 2009 well you can start here <?php //CONNECT TO THE DATABASE $link=mysql_connect('localhost','USERNAME HERE','PASSWORD HERE'); mysql_select_db('DATABASE_NAME_HERE'); //QUERY THE TABLE TO SEE IF COUPON WAS ALREADY DOWNLOADED BY THIS USER $sql='SELECT `id` FROM `coupon` WHERE `user_id`="'.$_COOKIE['user_id'].'" AND `coupon`="THE_COUPON_NAME" '; $res=mysql_query($sql) or die($sql."<br>".mysql_error()); $downloaded=(mysql_num_rows($res)>0)?true:false; if($download){ //IF DOWNLOADED echo "YOU ALREADY DOWNLOADED THIS COUPON!"; }else{ //IF NOT DOWNLOADED //INSERT INTO TABLE $sql='INSERT INTO `coupon` SET `user_id`="'.$_COOKIE['user_id'].'",`coupon`="THE_COUPON_NAME",`date`="'.time().'"'; mysql_query($sql) or die($sql."<br>".mysql_error()); //DISPLAY THE COUPON echo "your coupon here"; } ?> someone who actually knows phpbb can chime in Quote Link to comment https://forums.phpfreaks.com/topic/173822-one-time-popup-for-visitors/#findComment-916484 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.