This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ require_once('init.php'); //Databaseinfo som ligg sentralt lagra -> enkelt plass å hente infoen. session_start(); // Oppretter blank session. $db = new dbcon(); //Kjør i gang databasetilkobling if (isset($_POST['user']) || $_SESSION['innlogga'] != 1) { $user = mysql_real_escape_string($_POST['user'],$db->link); $passwd = mysql_real_escape_string($_POST['pass'],$db->link); $pass_enc = sha1($passwd); $query = "SELECT * FROM `%sbrukarar` WHERE `brukar` = '$user'"; $db->query($query); $bruker = mysql_fetch_array(); if ($bruker['passord'] == $pass_enc) { $_SESSION['innlogga'] = TRUE; $_SESSION['brukar'] = $user; echo "Logg ut"; } elseif ($_SESSION['innlogga'] == TRUE) { echo "Logg ut"; }else { echo '
'; die(); } } if ($_GET['action'] === "logout") { session_destroy(); } ?>