ShawnK
04-03-2005, 07:09 PM
I am having problems with my login script, it works but its very ineffeciant! Please tell me what you'd do!
<?php
/************************************************************************/
/* KurtzDownloadDB: Download Management System */
/* =========================================== */
/* Copyright (c) 2005 by Shawn Kurtz */
/* */
/* 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. */
/************************************************************************/
if(!defined("KDD")) die("<b>Error:</b> You cannot access this file directly!");
$act = stripslashes($_GET['act']);
if(isset($_SESSION['username']))
{
errorDie("You are already logged in!");
}
if(!isset($_POST['login']))
{
include("../$config[0]/themes/$config[1]/loginform.tpl");
die();
}
if(empty($_POST['username']) || empty($_POST['password']))
{
$error = "<b>KDD Error:</b> You must fill in all fields!";
include("../$config[0]/themes/$config[1]/loginform.tpl");
}
$uName = stripslashes(strtolower($_POST['username']));
$uPass = md5(stripslashes($_POST['password']));
$userInfo = $mysql->query("SELECT * FROM $db[4]_users WHERE `username` = '$uName'", 0);
if(empty($userInfo) || $uPass !== $userInfo['password'])
{
$error = "<b>KDD Error:</b> Incorrect Username/Password!";
include("../$config[0]/themes/$config[1]/loginform.tpl");
}
else
{
$_SESSION['userid'] = $userInfo['id'];
$_SESSION['username'] = $userInfo['username'];
header("Location ../$config[0]/index.php");
}
?>
<?php
/************************************************************************/
/* KurtzDownloadDB: Download Management System */
/* =========================================== */
/* Copyright (c) 2005 by Shawn Kurtz */
/* */
/* 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. */
/************************************************************************/
if(!defined("KDD")) die("<b>Error:</b> You cannot access this file directly!");
$act = stripslashes($_GET['act']);
if(isset($_SESSION['username']))
{
errorDie("You are already logged in!");
}
if(!isset($_POST['login']))
{
include("../$config[0]/themes/$config[1]/loginform.tpl");
die();
}
if(empty($_POST['username']) || empty($_POST['password']))
{
$error = "<b>KDD Error:</b> You must fill in all fields!";
include("../$config[0]/themes/$config[1]/loginform.tpl");
}
$uName = stripslashes(strtolower($_POST['username']));
$uPass = md5(stripslashes($_POST['password']));
$userInfo = $mysql->query("SELECT * FROM $db[4]_users WHERE `username` = '$uName'", 0);
if(empty($userInfo) || $uPass !== $userInfo['password'])
{
$error = "<b>KDD Error:</b> Incorrect Username/Password!";
include("../$config[0]/themes/$config[1]/loginform.tpl");
}
else
{
$_SESSION['userid'] = $userInfo['id'];
$_SESSION['username'] = $userInfo['username'];
header("Location ../$config[0]/index.php");
}
?>