/    Sign up×
Community /Pin to ProfileBookmark

Max submits limited to "X" number

Thanks to the help of this forum, google and reading here:
[url]http://www.php.net/quickref.php[/url]
In addition to Scott Henderson allowing me to use his script I’ve been able to make the following page:
[url]http://www.hotroddersauctions.com/trees/tournamenttime.php[/url]

I have two problems (maybe three) that I can’t seem to work-out.

I think that a new user gets an error in their “My Times” coloum but I’m not sure about that b/c I’m not a new user?

The real question I have is how can I limit a user to 5 submits?

And if I’m not using sessionid’s can I prevent resubmit on page refresh? reset only clears the time on the page, but doesn’t seem to clear the browser or something? The reason I want to do this is to prevent somebody from setting a good time and then hitting refresh over and over.

I know this is more than one question but I’ve been trying for days to figure out the no submit on refresh and the 5 submit limit and it seems to be beyond my abilities right now. please keep in mind that 2 weeks ago I didn’t even know that all php must start with <?php ? Thanks for the help!!

to post a comment
PHP

5 Comments(s)

Copy linkTweet thisAlerts:
@WebnerdMar 13.2006 — Browser cookies are a good option. Example:

[code=php]
<?

if(isset($_COOKIE["submissions"])){

if(isset($_POST) && sizeof($_POST)>0){

setcookie("submissions",$_COOKIE["submissions"]++,time()+60*60*24*7);

}

if($_COOKIE["submissions"]>=5){

echo "no more for you buddy!";

exit;
}

}else{
if(isset($_POST) && sizeof($_POST)>0){

setcookie("submissions",1,time()+60*60*24*7);

}
}
[/code]


And also, PHP does not have to start with <?php. It can start with <? if you have enable_short_tags on.
Copy linkTweet thisAlerts:
@72newbieauthorMar 13.2006 — I've tried that every which way I can think of and i keep getting an error "header already sent on line xx which is always this line:

setcookie("submissions",1,time()+60*60*24*7);


If I remove that line there is no error but it doesn't prevent posting over 5 times.

I see the line above it that looks similar, do they do the same thing?
Copy linkTweet thisAlerts:
@crh3675Mar 13.2006 — You need to put that code before any HTML output. Top of the page is best.
Copy linkTweet thisAlerts:
@72newbieauthorMar 13.2006 — Should this stand alone or does it need to be intergrated into my submit code? No matter what I seem to do I get the error on the same line.
Copy linkTweet thisAlerts:
@72newbieauthorMar 14.2006 — Can you explain this code and how it works?
×

Success!

Help @72newbie spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.18,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...