sulfericacid has asked for the wisdom of the Perl Monks concerning the following question:
You can see the script at http://sulfericacid.perlmonk.org/neopets/add.pl.
use strict; use warnings; use POSIX; use CGI qw/:standard/; require SDBM_File; my %list; my $list = "list.dbm"; #change to location of database tie %list, 'SDBM_File', $list, O_CREAT | O_RDWR, 0644; if ( !tied %list ) { print "database unsuccessful $!.\n"; } print header, start_html('Neopets I/S nickname list:'); print start_form(), table( Tr( td("Your username: "), td( textfield( -name => 'username', -size => 40 ) ) ), Tr( td("What you wish to be called: "), td( textfield( -name => 'askname', -size => 40 ) ) ), Tr( td( radio_group( -name => 'update', -values => [ 'add', 'rem' ] ) ), ), Tr( td(), td(submit) ), ), end_form(), hr(); print qq(<a href="list.pl">view the current list!</a><br><br><br>); if(param()){ my $username = param('username'); my $askname = param('askname'); my $update = param('update'); if($username){ if($username){ if($update eq "add"){ if(exists $list{$username}){ print "Username already exists in database.\n"; } else{ $list{$username} = $askname; print "Username was added to our system!<p>\n"; } } elsif($update eq "rem"){ if(exists $list{$username}){ del $list{$username}; print "Account information was removed from the sy +stem.\n"; } else{ print "Oops, it doesn't appear that username is in + our database.\n"; } } } else{ print "For this to work please add your username.\n"; } }else{ print "Unless your name is null, please go back and fill it in +.\n"; } } print end_html();
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: deleting item from database
by Zaxo (Archbishop) on Jun 21, 2003 at 17:31 UTC | |
by sulfericacid (Deacon) on Jun 21, 2003 at 17:38 UTC | |
by DrHyde (Prior) on Jun 21, 2003 at 19:59 UTC | |
|
Re: deleting item from database
by YuckFoo (Abbot) on Jun 21, 2003 at 18:07 UTC |