check if username already exists
git-svn-id: http://yolanda.mister-muffin.de/svn@235 7eef14d0-6ed0-489d-bf55-20463b2d70db
This commit is contained in:
parent
6262fd714e
commit
6ba502f6a4
2 changed files with 22 additions and 4 deletions
|
@ -56,6 +56,7 @@
|
|||
<string id="error_already_logged_in">You seem to be already logged in. Please log out to log in again.</string>
|
||||
<string id="error_username_password_do_not_match">Username and password do not match.</string>
|
||||
<string id="error_passwords_do_not_match">Passwords do not match.</string>
|
||||
<string id="error_username_already_registered">Your desired Username was already registered</string>
|
||||
<string id="error_insert_username">Please insert a username.</string>
|
||||
<string id="error_insert_password">Please insert a password.</string>
|
||||
<string id="error_repeat_password">Please repeat your password.</string>
|
||||
|
|
|
@ -22,11 +22,28 @@ elsif($query->param('user') and $query->param('pass') and $query->param('pass_re
|
|||
{
|
||||
if($query->param('pass') eq $query->param('pass_repeat'))
|
||||
{
|
||||
#do query
|
||||
$dbh->do(qq{insert into users (username, password, timestamp, locale) values ( ?, password( ? ), unix_timestamp(), ?)}, undef,
|
||||
$query->param("user"), $query->param("pass"), $page->{'locale'}) or die $dbh->errstr;
|
||||
my $sth = $dbh->prepare(qq{select id from users where username = ? limit 1 });
|
||||
|
||||
print $query->redirect("index.pl?information=information_registered");
|
||||
#execute query
|
||||
$sth->execute($query->param('user'));
|
||||
|
||||
#if something was returned the selected username already exists
|
||||
if($sth->fetchrow_array())
|
||||
{
|
||||
$page->{'registerform'} = [''];
|
||||
$page->{'message'}->{'type'} = "error";
|
||||
$page->{'message'}->{'text'} = "error_username_already_registered";
|
||||
|
||||
print output_page();
|
||||
}
|
||||
else
|
||||
{
|
||||
#insert new user
|
||||
$dbh->do(qq{insert into users (username, password, timestamp, locale) values ( ?, password( ? ), unix_timestamp(), ?)}, undef,
|
||||
$query->param("user"), $query->param("pass"), $page->{'locale'}) or die $dbh->errstr;
|
||||
|
||||
print $query->redirect("index.pl?information=information_registered");
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
Loading…
Reference in a new issue