Here's what I'd do...
I'm assuming this is not a "top-secret" type of thing and that your users aren't going to be hacking around wreaking mischief with the system.
1. Define your db fields as such:
Keycode
Name
email
status
Date or time or notes or something (I always throw in a couple of extra fields just for good measure)
2. Set user permissions to view & modify, you as admin would have all permissions.
The system would work like this:
You can upload a pre-filled file of keycodes (default.db) but be sure to include empty slots for all of your fields.
Example:
123-456789|||available|
567-891011|||available|
Or, you could add keycodes as you need to (or both)
3. Your users would log in and click a link (or be automatically taken) to a page that has the keycode and a place for them to enter their email address and name (this page is actually the modify_record page - but they don't know that). They enter their info and click "submit". This sets a hidden field that marks that keycode as "used" and keeps it from being displayed again. At this point they'd also receive an email with the keycode and perhaps you could have it send you one as well.
To do the above add the following to html_record_form (I'm assuming you will have some familiarity with the dbman script and can hack around and modify the html as well).
Code:
if ($in{'modify_form'}) {
print qq|<INPUT TYPE="hidden" NAME="status" VALUE="used">|;
} else {print qq|<INPUT TYPE="hidden" NAME="status" VALUE="available">|;}
Then customize your record layout for those getting keycodes (users)
Code:
if (($rec{'status'} eq "available") && ($in{'modify_form'})) {print qq|
<BR>$rec{'keycode'}
<BR>Enter your Name: <INPUT TYPE="text" NAME="name" VALUE="$rec{'name'}" SIZE="30" MAXLENGTH="100">
<BR>Enter your Email: <INPUT TYPE="text" NAME="email" VALUE="$rec{'email'}" SIZE="30" MAXLENGTH="100">
<BR>What ever other fields you want...
|;}
and don't forget to customize it for yourself to add keycodes
Code:
if($in{'add_form'}) {print qq|
<BR> Keycode: <INPUT TYPE="text" NAME="keycode" VALUE="$rec{'keycode'}" SIZE="30" MAXLENGTH="100">
<BR>Name: <INPUT TYPE="text" NAME="name" VALUE="$rec{'name'}" SIZE="30" MAXLENGTH="100">
<BR>Email: <INPUT TYPE="text" NAME="email" VALUE="$rec{'email'}" SIZE="30" MAXLENGTH="100">
<BR> etc, etc.
|;}
Then add the email script to html_modify_success:
Code:
open (MAIL, "|$mailprog -oi -t") or die;
print MAIL "To:$rec{'email'}\n";
print MAIL "From:admin\@yourdomain.com\n";
print MAIL "cc:admin\@yourdomain.com\n";
print MAIL "Subject: Keycode Requested\n";
print MAIL "MIME-Version: 1.0\n";
print MAIL "Content-Type: text/html; charset=us-ascii\n";
print MAIL "Content-Transfer-Encoding: 7bit\n";
print MAIL qq|
<HTML><BODY>
You can put your message here and get fancy with html markup
<P> Your requested key code is $rec{'keycode'} blah blah blah
</BODY>
</HTML>
|;
close MAIL
You can then add something like
status=available to the modify records link like this:
Code:
print qq!| <A HREF="$db_script_link_url&modify_form=1&status=available">Modify</A> ! if ($per_mod);
or you could have it do it automatically by adding the following under login_success
Code:
<META HTTP-EQUIV = REFRESH CONTENT = "0; URL=$db_script_link_url&modify_form=1&status=available">
of course you'd have to figure out someway to have the script pull up the next available record/keycode by using
&ID=next or something in the link without the script freaking out and wanting you to search for records.
This is what I came up with off of the top of my head. I'm sure there are much better ways to do this, but play with it and see what works and what doesn't. I'll poke around in the FAQ and see if there is a "next record" mod or something.
Good Luck!