Jump to content

Recommended Posts

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
Link to comment
https://forums.phpfreaks.com/topic/29009-3-days-users-can-only-do-this-once/
Share on other sites

[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
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,... thanks

And sorry for double posting :)
I would actually use 2 tables. One for the person and one for the paychecks. You can structure it like so

id - auto increment
userid - links to the persons id
checknum - interger
amount - interger
paydate - date field
claimed - 0-1 or yes no

now 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
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.
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
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
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
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?
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

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]
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 you

Ray


This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.