Re: Unique number in CGI

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

 Date:  Thu, 24 Feb 2000 11:26:57 +1300
 To:  <tristar(at)raex.com>,
<hwg-basics(at)hwg.org>
 References:  raex
  todo: View Thread, Original
I didn't see any reply to your query so here's one way:-

$number = int rand(99999);

This will give you a random whole number between
0 and 99999.

To output info to a webpage 
Well it depends on how you accessed the cgi script
If you accessed it using ssi with an "exec" command
for example then simply as follows:-

print "Content-type:text/html\n\n";  

print "The unique number is $number\n";

If you activated the script from a form or an <a href
tag then you will have to create the whole page 
something like this:-

print "Content-type:text/html\n\n";

print <<"HTMLHEADER";

<html>
<head><title>unique numbers</title>
</head>
<body>

HTMLHEADER
;

print "<h3 align=center>My unique numbers page</h3>";
print "My unique number is $number<br>";

print "</body></html>";


Hope this helps 
Peter Newton

----- Original Message ----- 
From: "Todd Eddy" <tristar(at)raex.com>

> How do I assign a unique number every time someone submits a form.  then
> how do I print that number on the CGI results? (kinda new to CGI)
> 
> --
> Todd Eddy
> tristar(at)raex.com
> http://www.vrillusions.com/
> 
> 
> 

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