2007-10-10 21:48:12 +00:00
|
|
|
require "/var/www/perl/include.pl";
|
|
|
|
|
|
|
|
#initialize session data
|
|
|
|
CGI::Session->name($session_name);
|
|
|
|
$query = new CGI;
|
|
|
|
$session = new CGI::Session;
|
|
|
|
|
|
|
|
#if username and password are passed put them into the database
|
|
|
|
if($query->param('user') and $query->param('pass')) {
|
|
|
|
#connect to db
|
2007-10-11 10:00:38 +00:00
|
|
|
my $dbh = DBI->connect("DBI:mysql:$database:$host", $dbuser, $dbpass) or die $dbh->errstr;
|
2007-10-10 21:48:12 +00:00
|
|
|
|
|
|
|
#save POST data in local variables
|
|
|
|
my $user = $query->param("user");
|
|
|
|
my $pass = $query->param("pass");
|
|
|
|
|
2007-10-11 10:00:38 +00:00
|
|
|
#do query
|
|
|
|
$dbh->do(qq{insert into users (username, password) values ('$user', password('$pass'))}) or die $dbh->errstr;
|
|
|
|
|
2007-10-10 21:48:12 +00:00
|
|
|
#disconnect db
|
2007-10-11 10:00:38 +00:00
|
|
|
$dbh->disconnect() or die $dbh->errstr;
|
2007-10-10 21:48:12 +00:00
|
|
|
|
|
|
|
#print a little confirmation
|
|
|
|
print $session->header();
|
|
|
|
print "done";
|
|
|
|
} else {
|
|
|
|
#if not, print register form
|
|
|
|
print $session->header();
|
|
|
|
print '<form action="" method="POST"><p>
|
|
|
|
<input name="user" type="text" size="30" maxlength="30">
|
|
|
|
<input name="pass" type="password" size="30" maxlength="30">
|
|
|
|
<input type="submit" name="register" value=" register ">
|
|
|
|
</p></form>';
|
|
|
|
}
|