The Web Design Group

... Making the Web accessible to all.

Welcome Guest ( Log In | Register )

 
Reply to this topicStart new topic
> Give a player points 1 time.
FrostTaco
post May 14 2016, 11:09 PM
Post #1


Member
***

Group: Members
Posts: 47
Joined: 26-April 16
Member No.: 24,193



Hi guys, today I was coding away with everything working until I noticed a problem. Players can refresh a link I give them to give them extra points. Basically, I have gleam.io giveaways, and one of the ways to enter is to use a link to my website, which allows you to gain 1, and only 1 point. However, if the user saves the link, they can just refresh the page and do anything and keep earning points. Points are stored in a file: useridcustom.json Of course, userid is replaced with the users id. How can I make a player use the link only once? Link example: corndog.corticalcafe.com/index.php?gid=1&pts=1 gid is the giveaway id, and pts of course is the points the player earns(The player cannot see the link until its been used so they cant change pts=1). Does anyone know of an easy way to allow players to use it once?

Note: It would be best if I don't have to store it in a file, as their will be a lot of giveaways, meaning the file would get real messy quickly.
User is offlinePM
Go to the top of the page
Toggle Multi-post QuotingQuote Post
CharlesEF
post May 15 2016, 04:15 AM
Post #2


Programming Fanatic
********

Group: Members
Posts: 1,981
Joined: 27-April 13
From: Edinburg, Texas
Member No.: 19,088



If I understand the problem correctly the only sure way of doing this is with a database. How/when/where is the json created? Is it a file or just a variable, PHP/Javascript?
User is offlinePM
Go to the top of the page
Toggle Multi-post QuotingQuote Post
FrostTaco
post May 15 2016, 09:01 AM
Post #3


Member
***

Group: Members
Posts: 47
Joined: 26-April 16
Member No.: 24,193



QUOTE(CharlesEF @ May 15 2016, 05:15 AM) *

If I understand the problem correctly the only sure way of doing this is with a database. How/when/where is the json created? Is it a file or just a variable, PHP/Javascript?

The json file is created when a player logs in for their first time in the cache folder. The file then can be edited so the user can change some information on their account. This file also stores the players points. I used php to make the file.
User is offlinePM
Go to the top of the page
Toggle Multi-post QuotingQuote Post
CharlesEF
post May 15 2016, 06:43 PM
Post #4


Programming Fanatic
********

Group: Members
Posts: 1,981
Joined: 27-April 13
From: Edinburg, Texas
Member No.: 19,088



QUOTE(FrostTaco @ May 15 2016, 09:01 AM) *
The json file is created when a player logs in for their first time in the cache folder. The file then can be edited so the user can change some information on their account. This file also stores the players points. I used php to make the file.

So each player has their own json file, correct? How is the link created? Do you use PHP to parse the json file and create the link? If yes then you could remove the data for the points after they are used and re-write the json file.
User is offlinePM
Go to the top of the page
Toggle Multi-post QuotingQuote Post
FrostTaco
post May 16 2016, 03:51 PM
Post #5


Member
***

Group: Members
Posts: 47
Joined: 26-April 16
Member No.: 24,193



QUOTE(CharlesEF @ May 15 2016, 07:43 PM) *

QUOTE(FrostTaco @ May 15 2016, 09:01 AM) *
The json file is created when a player logs in for their first time in the cache folder. The file then can be edited so the user can change some information on their account. This file also stores the players points. I used php to make the file.

So each player has their own json file, correct? How is the link created? Do you use PHP to parse the json file and create the link? If yes then you could remove the data for the points after they are used and re-write the json file.


I don't really understand, and yes each player has their on json file
Not sure if this is what you said, but here is what I think will work: I generate a file with a list of different codes. In the url, I change gid to id=code when the player uses that link, it removes the code from the file. Going to try this smile.gif

EDIT: Is their any quick way I can just easily generate lots of 7 or 8 digit codes(letters and #s)?

This post has been edited by FrostTaco: May 16 2016, 03:58 PM
User is offlinePM
Go to the top of the page
Toggle Multi-post QuotingQuote Post
CharlesEF
post May 17 2016, 09:26 AM
Post #6


Programming Fanatic
********

Group: Members
Posts: 1,981
Joined: 27-April 13
From: Edinburg, Texas
Member No.: 19,088



Yes, that is the idea. Each player will have their own points file. When the page is served up PHP can parse the file and create then echo the link. When the player clicks on the link PHP should remove that entry from the file. This way, if the user reloads the page the link will not be created again.

I still think it would be better if you used a database for this.
User is offlinePM
Go to the top of the page
Toggle Multi-post QuotingQuote Post
FrostTaco
post May 20 2016, 10:04 PM
Post #7


Member
***

Group: Members
Posts: 47
Joined: 26-April 16
Member No.: 24,193



QUOTE(CharlesEF @ May 17 2016, 10:26 AM) *

Yes, that is the idea. Each player will have their own points file. When the page is served up PHP can parse the file and create then echo the link. When the player clicks on the link PHP should remove that entry from the file. This way, if the user reloads the page the link will not be created again.

I still think it would be better if you used a database for this.

But how does the player actually get to that page in the first place?
User is offlinePM
Go to the top of the page
Toggle Multi-post QuotingQuote Post
CharlesEF
post May 21 2016, 12:57 AM
Post #8


Programming Fanatic
********

Group: Members
Posts: 1,981
Joined: 27-April 13
From: Edinburg, Texas
Member No.: 19,088



QUOTE(FrostTaco @ May 20 2016, 10:04 PM) *
But how does the player actually get to that page in the first place?

Well, how do you currently create the link? It is at this point that I suggest you incorporate the new program logic. You have never posted your code, only a description of the problem. So, I can't tell you exactly how to do it.

This post has been edited by CharlesEF: May 21 2016, 01:01 AM
User is offlinePM
Go to the top of the page
Toggle Multi-post QuotingQuote Post
FrostTaco
post May 21 2016, 08:50 AM
Post #9


Member
***

Group: Members
Posts: 47
Joined: 26-April 16
Member No.: 24,193



QUOTE(CharlesEF @ May 21 2016, 01:57 AM) *

QUOTE(FrostTaco @ May 20 2016, 10:04 PM) *
But how does the player actually get to that page in the first place?

Well, how do you currently create the link? It is at this point that I suggest you incorporate the new program logic. You have never posted your code, only a description of the problem. So, I can't tell you exactly how to do it.


That's the problem, I don't have that code! I was thinking maybe the webpage should pick a link when its loaded for the first time with a special id(http://corndog.corticalcafe.com/greward.php?rid=id). Now it saves that code for just that user and just for the id(rid). If another person uses that id though, they get a completely different code. However, if the first person uses a different id, they then get a different code. Do you think this would work? I'm just not sure now tongue.gif I'm pretty sure I would have to make a new file for every person called something like usedids-playerid.json

This post has been edited by FrostTaco: May 21 2016, 08:50 AM
User is offlinePM
Go to the top of the page
Toggle Multi-post QuotingQuote Post
FrostTaco
post May 21 2016, 02:04 PM
Post #10


Member
***

Group: Members
Posts: 47
Joined: 26-April 16
Member No.: 24,193



QUOTE(FrostTaco @ May 21 2016, 09:50 AM) *

QUOTE(CharlesEF @ May 21 2016, 01:57 AM) *

QUOTE(FrostTaco @ May 20 2016, 10:04 PM) *
But how does the player actually get to that page in the first place?

Well, how do you currently create the link? It is at this point that I suggest you incorporate the new program logic. You have never posted your code, only a description of the problem. So, I can't tell you exactly how to do it.


That's the problem, I don't have that code! I was thinking maybe the webpage should pick a link when its loaded for the first time with a special id(http://corndog.corticalcafe.com/greward.php?rid=id). Now it saves that code for just that user and just for the id(rid). If another person uses that id though, they get a completely different code. However, if the first person uses a different id, they then get a different code. Do you think this would work? I'm just not sure now tongue.gif I'm pretty sure I would have to make a new file for every person called something like usedids-playerid.json


Just noticed a much easier way todo it, thanks anyways smile.gif
User is offlinePM
Go to the top of the page
Toggle Multi-post QuotingQuote Post
FrostTaco
post May 21 2016, 06:34 PM
Post #11


Member
***

Group: Members
Posts: 47
Joined: 26-April 16
Member No.: 24,193



So sorry, but I was wondering, how do I refresh the page on button click, but add the parameter rep=1 while keeping the other parameters in the url?
User is offlinePM
Go to the top of the page
Toggle Multi-post QuotingQuote Post
CharlesEF
post May 23 2016, 02:15 PM
Post #12


Programming Fanatic
********

Group: Members
Posts: 1,981
Joined: 27-April 13
From: Edinburg, Texas
Member No.: 19,088



QUOTE(FrostTaco @ May 21 2016, 06:34 PM) *

So sorry, but I was wondering, how do I refresh the page on button click, but add the parameter rep=1 while keeping the other parameters in the url?

Since you say a button click then you would need to use javascript. On button click you would need to read the current HREF (assign to a variable) then add whatever query string you want to that variable then use the new link/variable to load the page.
User is offlinePM
Go to the top of the page
Toggle Multi-post QuotingQuote Post

Reply to this topicStart new topic
1 User(s) are reading this topic (1 Guests and 0 Anonymous Users)
0 Members:

 



- Lo-Fi Version Time is now: 28th March 2024 - 04:12 AM