Re: Unique number in CGI

by "Peter Newton" <c-newton(at)ihug.co.nz>

 Date:  Thu, 24 Feb 2000 22:13:11 +1300
 To:  <hwg-basics(at)hwg.org>
 References: 
  todo: View Thread, Original
Ahh! Yes

Your quite right. I agree simply create a file with a number in it and
increment the number each time you use it. The number will be
entirely predictable though like pages in a book but still unique.

Thanks
Peter Newton

> G'day
>
> >I didn't see any reply to your query so here's one way:-
> >$number = int rand(99999);
>
> Only one problem with that approach - a random number is not always a
> unique number.  In fact, it is (remotely) possible you get the same number
> twice in a row...
>
> I sent a private reply to the original poster, suggesting they draw the
> number from a "page counter" file.  You know - put a cgi counter on the
> page and access the file that the counter uses to keep track of hits.
>
> Unless that counter file is interfered with, it will only ever increase
> (until it gets so big that an overflow occurs), meaning it will be unique
> every time it is accessed.
>
> Of course, a separate "counter" file can be set up and used (and
> incremented) by the form submission script - which would overcome a
> potential problem with proxys and caches.
>
> Regards
> --
> Bert Doorn, Web Developer
> http://www.betterwebdesign.com.au
>

HTML: hwg-basics mailing list archives, maintained by Webmasters @ IWA