Monkuar Posted December 17, 2011 Share Posted December 17, 2011 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? Quote Link to comment https://forums.phpfreaks.com/topic/253389-i-dont-necessarily-need-php-help-but-some-logic/ Share on other sites More sharing options...
scootstah Posted December 17, 2011 Share Posted December 17, 2011 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. Quote Link to comment https://forums.phpfreaks.com/topic/253389-i-dont-necessarily-need-php-help-but-some-logic/#findComment-1298889 Share on other sites More sharing options...
Monkuar Posted December 17, 2011 Author Share Posted December 17, 2011 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: This helps to show, people who donated 5 Dollars, will get access through 1 through 10 stars.png. Quote Link to comment https://forums.phpfreaks.com/topic/253389-i-dont-necessarily-need-php-help-but-some-logic/#findComment-1298898 Share on other sites More sharing options...
kicken Posted December 17, 2011 Share Posted December 17, 2011 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. Quote Link to comment https://forums.phpfreaks.com/topic/253389-i-dont-necessarily-need-php-help-but-some-logic/#findComment-1298910 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.