Jump to content

I don't necessarily need php Help, but some Logic!


Monkuar

Recommended Posts

Hey guys,  I am not really asking for pure php code, as I know alot of if's and switches could do this, but I am thinking of a easier method, of using for each or something to make it alot more better (performance wise) here it goes.

 

 

 

I have 70 images, 1.png to 70.png, they are STARS.  People on my forum software can upgrade there account via paypal to become a "Site Donor"

 

I use the paypal's IPN to update the "amount" field value in mysql for each member.  So if a user donates 10$, and then he donates 10$ tomorrow, the "amount" field will have a total of "20$" in it.

 

Now I need to show a page where it list's all 1-70.png STARS, and it will have a radio button next to each star for them to select (Based on the amount they donate) So if a person has only dated 5$ dollars, they will have access to starts 1 through 10.png.  If a person donated 20$ they will have access to 1-20.png Stars to chose from, (and so on)

 

What would be the easiest way to check the input so people can't tamper with my form value to get a let's say 50.png star when they only donated like 10 dollars?

 

Should I use just a simple  switch function with 70 Cases? Or is there a easier method? and how would I go about storing a value in a field when they make a payment so then I can just simply check that field with the users input so they can't tamper the data and try to get a higher star?

Link to comment
Share on other sites

Maybe make a column in the user table called "max_stars". Then when they donate you just figure out how many stars they should have and then update this column. So from your example if they donated $5, max_stars would be 10.

 

Then when they choose a star make sure it doesn't exceed max_stars.

Link to comment
Share on other sites

Maybe make a column in the user table called "max_stars". Then when they donate you just figure out how many stars they should have and then update this column. So from your example if they donated $5, max_stars would be 10.

 

Then when they choose a star make sure it doesn't exceed max_stars.

 

very good idea thank you

 

this is what it looks like so far:

 

pk1q.png

 

This helps to show, people who donated 5 Dollars, will get access through 1 through 10 stars.png.

 

Link to comment
Share on other sites

Your already calculating how many stars they have access to based on the amount.  Just do that same calculation when they submit the form and make sure their selected start falls in that range.  Your range seems a bit confusing to me though.  Would have expected $20 to get stars 1-40 if $5 gets you 1-10.

 

No need for a max stars column, just use their total donation amount to calculate the max stars on the fly.

Link to comment
Share on other sites

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.