2 session_start(); // start session.
3 include('configuration');
5 if($_SESSION['slogged'] != ''){
7 include('menulist.html');
8 echo "<br><div align=\"center\">Already logged in as ".$_SESSION['susername']."...</div>";
12 if(!isset($_POST['submit'])) {
14 include('menulist.html');
15 loginhtml("Members only. Please login to access.");
19 // get username and password
20 $username = $_POST['username'];
21 $password = $_POST['password'];
23 // register username and logged as session variables.
24 session_register("susername");
25 session_register("slogged");
27 //set session variables
28 $_SESSION["susername"] = $username;
29 $_SESSION["slogged"] = false;
32 $handle = sqlite3_open($db) or die("Could not open database");
34 $query = "SELECT * FROM login where username=\"$username\"";
36 $result = sqlite3_query($handle, $query) or die("Error in query: ".sqlite3_error($handle));
38 if (($row = sqlite3_fetch_array($result)) != '') {
39 if(md5($password) == $row["password"])
48 // Unset session variables.
51 include('menulist.html');
52 loginhtml("Incorrect login information, please try again. You must login to access.");
58 $referer = $_GET['referer'];
59 $_SESSION["slogged"] = true;
61 header('Location: '.$referer);
65 include('menulist.html');
66 echo "<br><div align=\"center\">Logged in sucessfully...<//div><//body><//html>";
71 function loginhtml($info)
74 <form action="<?=$PHP_SELF.$referer?><?if($QUERY_STRING){ echo"?". $QUERY_STRING;}?>" method="POST">
75 <p align="center"><?=$info?></p>
76 <table align="center" border="0">
82 <input type="text" name="username">
90 <input type="password" name="password">
94 <th colspan="2" align="right">
95 <input type="submit" name="submit" value="Login">