[Date Prev][Date Next][Thread Prev][Thread Next][Interchange by date
][Interchange by thread
]
[ic] [counter]
>
> I've been reading up on the [counter] tag on the IC resource site.
>
> I need a form to auto generate a random 3 digit numerical code and insert it
> into a database table. I'd like the numbers to be very speratic such as
> "784" and the next one might be "239", etc.
>
> More info on my appliation:
>
> New customers will receive this "key" in their email to verify they entered
> a valid email address. The last step of the signup process will ask them
> for this key.
>
> Can someone provide an example using this tag? I don't see anything in the
> archives relating to this topic.. thanks.
>
The [counter] tag won't generate random numbers for you.
You could create a UserTag like this:
UserTag generate_key Order length
UserTag generate_key Routine <<EOR
sub {
my $length = shift || 1;
my $out;
$out .= int(rand(10)) for (1 .. $length);
$out;
}
EOR
...and call it like this: [generate-key length=3]
Once you have the number, you can put it into the database table
in any way you see fit.
--
_/ _/ _/_/_/_/ _/ _/ _/_/_/ _/ _/
_/_/_/ _/_/ _/ _/ _/ _/_/ _/ K e v i n W a l s h
_/ _/ _/ _/ _/ _/ _/ _/_/ kevin@cursor.biz
_/ _/ _/_/_/_/ _/ _/_/_/ _/ _/
- References:
- [ic] [counter]
- From: interchange-users@interchange.redhat.com (Jim Webster)