<?
#############################################################################
# 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 3 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, see <http://www.gnu.org/licenses/>. #
#############################################################################
ob_start();
session_start();
include('../includes/dbconnect.inc.php');
if(isset($_POST['submit'])){
// define input vars
$username = $_POST['username'];
$password = $_POST['password'];
$username = mysql_real_escape_string($username);
$password = md5($password);
$query = mysql_query("SELECT * FROM administrators WHERE username = '$username' && password = '$password'") or die(mysql_error());
$count = mysql_num_rows($query);
$row = mysql_fetch_assoc($query);
if($count == 1){
$_SESSION['username'] = $username;
$_SESSION['userid'] = $row['id'];
header("location:../index.php");
}
else{
header("location:../login.php?error=1");
}
}
ob_end_flush();
?>