piznac Posted November 30, 2006 Share Posted November 30, 2006 I have a "fake" money system, that gives out a pay check on friday. The user will have 3 days to collect this check after that it disapears untill next friday. I asked for help on this part on here and got a very simple solution (thanks again). Problem is there is no way to stop someone from getting like a million checks in one day. So I was thinking I could somehow log the user name and date in the DB but I really dont know where to start on that one. So basically something like this:[code]if($user has already clicked this once){drop link;}[/code]Can anyone point me in the right direction for this?here is the code for the check system(also inculded in this is a link to update db for cash):[code]<?php $today = date("w") + 1;if($today == 6){ echo "<img src=images/capitalwage_get.jpg width=100 height=100 />";}elseif($today == 7){echo "<img src=images/capitalwage_get.jpg width=100 height=100 />";}elseif($today == 8){echo "<img src=images/capitalwage_get.jpg width=100 height=100 />";}elseif($today == 8){ echo "<img src=images/capitalwage_get.jpg width=100 height=100 />";}else{echo "<img src=images/capitalwage.jpg width=100 height=100 />";}?>[/code]plus I just noticed an error in this ;D Quote Link to comment https://forums.phpfreaks.com/topic/29009-3-days-users-can-only-do-this-once/ Share on other sites More sharing options...
.josh Posted November 30, 2006 Share Posted November 30, 2006 can you show a db structure? Quote Link to comment https://forums.phpfreaks.com/topic/29009-3-days-users-can-only-do-this-once/#findComment-132893 Share on other sites More sharing options...
The Little Guy Posted November 30, 2006 Share Posted November 30, 2006 you need to save the date into the database [CODE]$num_days = date("Y-m-d") - $row['paydate'];if($num_days > 3){ //don't allow get paid}else{ //allow get paid}[/CODE] Quote Link to comment https://forums.phpfreaks.com/topic/29009-3-days-users-can-only-do-this-once/#findComment-132897 Share on other sites More sharing options...
piznac Posted November 30, 2006 Author Share Posted November 30, 2006 [code]CREATE TABLE `members` ( `name` text, `status` text, `country` text, `time` text, `games` longtext, `au` int(128) NOT NULL auto_increment, `pass` varchar(100) NOT NULL default '', `t_cash` int(254) default NULL, `l_cash` int(254) default NULL, `points` int(254) default NULL, PRIMARY KEY (`au`)) ENGINE=MyISAM DEFAULT CHARSET=latin1 AUTO_INCREMENT=440 ;[/code]this is the main table I will be dealing with,.. hope this is what you were looking for Quote Link to comment https://forums.phpfreaks.com/topic/29009-3-days-users-can-only-do-this-once/#findComment-132902 Share on other sites More sharing options...
piznac Posted November 30, 2006 Author Share Posted November 30, 2006 Ok thanks little guy,.. but how would I record the "paydate"? Maybe Im missing something..lolOh wait,.. ok I am a dummy,.. I see,.. thanks that should work Quote Link to comment https://forums.phpfreaks.com/topic/29009-3-days-users-can-only-do-this-once/#findComment-132904 Share on other sites More sharing options...
piznac Posted November 30, 2006 Author Share Posted November 30, 2006 ok wait I spoke to soon,. that wont work. I need something that will stop them from getting paid more then once in that 3 day period then reset for the next week,.. or something like that. Little guy if I missed something please explain.I think you put me in the right direction Little Guy,... thanksAnd sorry for double posting :) Quote Link to comment https://forums.phpfreaks.com/topic/29009-3-days-users-can-only-do-this-once/#findComment-132911 Share on other sites More sharing options...
craygo Posted November 30, 2006 Share Posted November 30, 2006 I would actually use 2 tables. One for the person and one for the paychecks. You can structure it like soid - auto incrementuserid - links to the persons idchecknum - intergeramount - intergerpaydate - date fieldclaimed - 0-1 or yes nonow you can enter as many checks as you like and have a claim system and also search on only unclaimed checks and such. and since you have a date field you can manipulate the searches any way you like.You should also put and auto increment field in your members table to have a unique id for all your users. Also makes searches faster and you don't have to deal with strings, uppercase, lowercase matches when running queries for updates.Ray Quote Link to comment https://forums.phpfreaks.com/topic/29009-3-days-users-can-only-do-this-once/#findComment-132922 Share on other sites More sharing options...
piznac Posted November 30, 2006 Author Share Posted November 30, 2006 Yeah I see what your saying,.. I have multiple tables. But I really dont see any reason to seperate this data. If I did a "checks" table vs 260+ members with a paycheck each week. Within 6 months I could have thousands of records in the checks table. Where with the one table it is just updating the total cash amount. I think this is my error for not explaining enough (and showing all the tables :)). Thanks for the help my man. Quote Link to comment https://forums.phpfreaks.com/topic/29009-3-days-users-can-only-do-this-once/#findComment-132938 Share on other sites More sharing options...
craygo Posted November 30, 2006 Share Posted November 30, 2006 That's 13000+ records a year. My database has close to 400,000 records in it and don't have any issues. This is what a server side database is for. Handling obsene amounts of data!! I wouldn't worry about it. I still think the 2 tables are your best and most organized solution. But up to you.If you want to use the one table deal can you explain what each field is for. Some like "au". What is that??Ray Quote Link to comment https://forums.phpfreaks.com/topic/29009-3-days-users-can-only-do-this-once/#findComment-132948 Share on other sites More sharing options...
piznac Posted November 30, 2006 Author Share Posted November 30, 2006 Yeah I hear ya,.. Ive never had a DB that big..LOL. Kinda scares me. And the "au" (cant quite remember why I named it that) is the member ID you spoke of Quote Link to comment https://forums.phpfreaks.com/topic/29009-3-days-users-can-only-do-this-once/#findComment-132952 Share on other sites More sharing options...
piznac Posted November 30, 2006 Author Share Posted November 30, 2006 CREATE TABLE `members` ( `name` text, -- is member name `status` text, -- is rank of member `country` text, -- is country in which they are `time` text, -- is there timezone `games` longtext, -- is list of games they play `au` int(128) NOT NULL auto_increment, -- member ID `pass` varchar(100) NOT NULL default '', -- is there password `t_cash` int(254) default NULL, -- is total cash `l_cash` int(254) default NULL, -- is less cash(which I dont think I need) `points` int(254) default NULL, -- this will be a ongoing points system PRIMARY KEY (`au`)) ENGINE=MyISAM DEFAULT CHARSET=latin1 AUTO_INCREMENT=440 ;now I do have other tables to set info on "check" amounts of each rank and such Quote Link to comment https://forums.phpfreaks.com/topic/29009-3-days-users-can-only-do-this-once/#findComment-132956 Share on other sites More sharing options...
craygo Posted November 30, 2006 Share Posted November 30, 2006 First thing you have to do is add a field for a date. You working with dates you will need to know when the last check was issued.How will the check amount be comprised??You will still have to have another field to flag the latest check as being "claimed" or not.Ray Quote Link to comment https://forums.phpfreaks.com/topic/29009-3-days-users-can-only-do-this-once/#findComment-132965 Share on other sites More sharing options...
piznac Posted November 30, 2006 Author Share Posted November 30, 2006 well I was thinking that if I added the date field,.. I could record the date when a check is recieved. Then use the formula above(or the oppisite of it) to say if the date is less then 3 days then no check. And there will either be a set check ($20) or a amount for each rank stored in the ranks table. I really dont know what you mean with the claimed thing,.. how would that work with the yes or no? Quote Link to comment https://forums.phpfreaks.com/topic/29009-3-days-users-can-only-do-this-once/#findComment-132971 Share on other sites More sharing options...
craygo Posted November 30, 2006 Share Posted November 30, 2006 The claim thing is for one of your statements above. If the check is not claimed in 3 days blah blah blah. So you need something to flag that is has been received, or claimed, so you can set things up properly.example: if the check is in the table but not claimed it does not get added to their cash. also without a field to claim the check the user can go to the site and keep claiming the check a bunch of times. Also this claim field would flag a link to collect the check.I am just Going through this cause you want to design this correctly right from the start. 3/4 of the way through your project you decide that "something else" would be a nice feature, then you are stuck starting all over again.Ray Quote Link to comment https://forums.phpfreaks.com/topic/29009-3-days-users-can-only-do-this-once/#findComment-132979 Share on other sites More sharing options...
piznac Posted November 30, 2006 Author Share Posted November 30, 2006 Hmm,.. ok considering I know very little about DB structure. I see your point to a degree. I will give this some thought. Thanks for taking the time to try to educate me. seriously Quote Link to comment https://forums.phpfreaks.com/topic/29009-3-days-users-can-only-do-this-once/#findComment-132981 Share on other sites More sharing options...
piznac Posted November 30, 2006 Author Share Posted November 30, 2006 Ok I got this all written but for some reason the "paydate" refuses to update in the database but the "pay" updates fine. Is it the format or what?[code]<?php//get todays date and paydate,.. minus the two to get difference. If difference is more or equal to 3 days stop.$today = date("Y-m-d");$date_parts2 = explode("-", $today);$today_date=gregoriantojd($date_parts2[1], $date_parts2[2], $date_parts2[0]);$last_pay = $row_user['payday'];$date_parts3 = explode("-", $last_pay);$pay_date=gregoriantojd($date_parts3[1], $date_parts3[2], $date_parts3[0]);echo $today; $diff = $today_date - $pay_date;echo "<br>$diff";if($diff <= 3){die ("You have already recieved your paycheck this week");}$s_cash = $row_user['t_cash'];$sal = $row_ranks['salary'];$num = $row_user['au'];//add salary + insert new cash$total = $s_cash + $sal;mysql_select_db($database_wrl, $wrl);$sql = "UPDATE members SET t_cash = $total, payday = $today WHERE au =$num";$cash = mysql_query($sql, $manage) or die(mysql_error());echo "You have been paid, you will be returned to the main page shortly.";?>[/code] Quote Link to comment https://forums.phpfreaks.com/topic/29009-3-days-users-can-only-do-this-once/#findComment-133068 Share on other sites More sharing options...
craygo Posted December 1, 2006 Share Posted December 1, 2006 What format is your payday field. did you make it a date, datetime, timestamp??? Also if it is a date you need to put the date in single quotes.[code]$sql = "UPDATE members SET t_cash = '$total', payday = '$today' WHERE au = '$num'";[/code]I usually put everything in quotes just to make sure, but up to youRay Quote Link to comment https://forums.phpfreaks.com/topic/29009-3-days-users-can-only-do-this-once/#findComment-133390 Share on other sites More sharing options...
piznac Posted December 1, 2006 Author Share Posted December 1, 2006 Im not sure why but I always run into a problem when I do that with the update,.. but I'll give it a go. Did you see anything else wrong? Quote Link to comment https://forums.phpfreaks.com/topic/29009-3-days-users-can-only-do-this-once/#findComment-133411 Share on other sites More sharing options...
piznac Posted December 1, 2006 Author Share Posted December 1, 2006 well I'll be darn that seems to have done the trick,.. thanks you sirthis one can be marked as solved Quote Link to comment https://forums.phpfreaks.com/topic/29009-3-days-users-can-only-do-this-once/#findComment-133422 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.