Edit Comics Account

% if ($mesg) { <% $mesg %>


% }

Login: <% $user %>
Password:
Password (again):
Email Address:
<%init> my ($email, $password, $mesg, $user, $dbh, $sth); $user = $m->comp('m/get_user'); $dbh = $m->comp('m/connect'); if ($ARGS{action} eq 'Change') { if (!length($ARGS{password}) || !length($ARGS{password2})) { $mesg = 'Please enter a password twice'; } elsif ($ARGS{password} ne $ARGS{password2}) { delete $ARGS{password}; delete $ARGS{password2}; $mesg = 'Passwords do not match'; } elsif ($ARGS{email} !~ /^[^\@]+\@[^\@\.]+\..+$/) { $mesg = 'Please choose a valid email address'; } else { $dbh->do(sprintf( 'update user set password = %s, email = %s where user = %s', map { $dbh->quote($_) } ($ARGS{password}, $ARGS{email}, $user))); $mesg = 'Account updated; Back to main page'; } } else { $sth = $dbh->prepare('select password, email from user where user = ?'); $sth->execute($user); @ARGS{qw(password email)} = $sth->fetchrow_array; $ARGS{password2} = $ARGS{password}; $sth->finish; } $dbh->disconnect;