perlgurl1020 has asked for the wisdom of the Perl Monks concerning the following question:
sub notify { my ($notifications) = @_; $App::session->param('notifications', $notifications); return $notifications; #not sure what to include to complete #$notifications.= $webnotifications } sub pop_notifications { print pop($App::notifications); reset @App::errs; #not sure how to complete } sub act_login { my $username = $App::q->param('username'); my $password = $App::q->param('Password' ); my $name = $App::q->param('name'); my $email = $App::q->param('email'); my @errs; if ($username eq '') { push @errs, "missing username"; } if ($password eq '') { push @errs, "missing password"; } if ($email eq '') { push @errs, "missing email"; } my ($already_exists) = $App::dbh->selectrow_array("SELECT 1 FROM use +r where username=?", undef, $username); if ($already_exists) { push @errs, "account already exists"; } if (scalar(@errs) == 0) { my $digest = sha1_base64($password); $App::dbh->do("INSERT INTO user(username, password_chksum, email, +name) VALUES (?, ?, ?, ?)", undef, $username,$digest,$email,$name); notify("account created"); $App::session->param('username', $username); App::redirect("myaccount"); } else { notify("errors: ".join(', ', @errs)); App::redirect("createuser"); }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Printing notifications to user for web app
by Anonymous Monk on Sep 08, 2015 at 03:27 UTC |