]> Softwares of Agnibho - simpleipd.git/blob - www/login.php
Bugfix
[simpleipd.git] / www / login.php
1 <?php
2 require(dirname(__DIR__)."/require.php");
3 $error="";
4 if(!empty($_GET["action"]) && $_GET["action"]=="logout"){
5 $_SESSION["user"]=null;
6 $_SESSION["group"]=null;
7 }
8 if(!empty($_POST["username"]) && !empty($_POST["password"])){
9 if($db->checkUser($_POST["username"], $_POST["password"])){
10 $_SESSION["user"]=$_POST["username"];
11 $_SESSION["group"]=$db->getGroup($_SESSION["user"])->fetchArray()["usergroup"];
12 $_SESSION["department"]=$db->getDepartment($_SESSION["user"])->fetchArray()["department"];
13 header("Location: index.php");
14 exit();
15 }
16 else{
17 $error="<div class='alert alert-danger'>Username or password is incorrect.</div>";
18 }
19 }
20 //header("Location: view.php?pid=".$_GET["pid"]);
21 //exit();
22 ?>
23 <!DOCTYPE html>
24 <html>
25 <head>
26 <?php include(CONFIG_LIB."head.php");?>
27 <title>Login</title>
28 </head>
29 <body>
30 <div class="container">
31 <?php include(CONFIG_LIB."top.php");?>
32 <?php echo $error;?>
33 <form method="post">
34 <input class="m-2 form-control" type="text" name="username" placeholder="Username" required>
35 <input class="m-2 form-control" type="password" name="password" placeholder="Password" required>
36 <button class="m-2 btn btn-primary" type="submit">Login</button>
37 </form>
38 </div>
39 <?php include(CONFIG_LIB."foot.php");?>
40 </body>
41 </html>