ok, i did all of that, but it still doesnt think the passwords match...i have no idea...let me include the files, and maybe you could tell me what you think it maybe?
login_check.php
<?
// this needs to be on every page, it makes it remember all of the set variables that is done on the login_script.php
session_start();
$sid = session_id();
if (session_is_registered("valid_user")) {
session_save_path("$sid.txt");
}
else { header ("Location: login.php"); }
?>
login_script.php
<?
session_start();
include ("config.php");
//checking to see if you have any users in the database, if so, the script continues, if not, it stops and lets you know
$usersquery=mysql_query("SELECT username FROM users")
or die ("The query on the number of users didn't work. ".mysql_error());
if (mysql_num_rows($usersquery) == "0") {
print "Deleted all ".
"of the users. That's no good.<br><br>If you are not the admin of this site, please email him/her at <a href=\"mailto:$admin_address\">$admin_address</a> to let him/her know that you received the error message.";
exit();
}
$ip_address = "$REMOTE_ADDR";
//lock out option
//if you want people to be locked out after 3 incorrect logins set this as "1"
//if you don't want to used this option, set this as "0" in config.php
if ($iplockout == "1") {
$loginquery=mysql_query("SELECT * FROM logins WHERE ip_address = '$ip_address' AND incorrect")
or die ("ip_address check/logins check query didn't work ".mysql_error());
$logindata = mysql_fetch_object ($loginquery);
if (mysql_num_rows($loginquery) >= "4") {
print "You have been locked out. Too many incorrect logins from ip address: $ip_address";
exit();
}
}
$password = md5($password);
// If $username and $password are set, match data against users table
$query=mysql_query("SELECT * FROM users WHERE username = '$username' AND password = '$password'")
or die ("For some reason the script wasn't able to check the username/password. ".mysql_error());
// If num_rows from users table = 1, set session variables
if (mysql_num_rows($query) == "1") {
session_start();
// Declaring some varibles
$valid_user = $username;
$id = session_id();
$ip_address = "$REMOTE_ADDR";
$data = mysql_fetch_object ($query);
$seclevel = $data->securitylevel; // this declares the security level varibles
$rowid = $data->id;
$datetime = date("n-d-y@h:iA", time() + 3600);
// adds 1 to the users "logincount" in the users table. that way you see how many times a person has logged in
mysql_query("UPDATE users SET logincount = logincount+1 WHERE (username = '$username')")
or die("Bad query: ".mysql_error());
/*
the 4 lines below this comment registers variables so you can "call" this variables on other secure pages
example:
print "You logged in as: $valid_user";
that code will display the users name
*/
session_register("valid_user");
session_register("ip_address");
session_register("id");
session_register("seclevel");
$password = md5($password);
// inserting login information, 1 = correct login
$insert = "INSERT INTO logins(datetime, ip_address, username, password, correct, incorrect) ".
"VALUES('$datetime', '$ip_address', '$username', '$password', '1', '0')" or die("Bad query: ".mysql_error());
$mysql_insert = mysql_query($insert, $mysql_link)
or die("Please notify the admin that the script is connecting to the database, but not inserting the information ".mysql_error());
//moves you to the logged in page
header("Location: ./index.php?sid=$id");
exit; // exit; "cancels the script"
}
// if the data given is incorrect/doesn't match...
if (mysql_num_rows($query) == 0) {
$password = md5($password);
// inserting login information, 0 = incorrect login
$insert = "INSERT INTO logins(datetime, ip_address, username, password, correct, incorrect) ".
"VALUES('$datetime', '$ip_address', '$username', '$password', '0', '1')" or die("Bad query: ".mysql_error());
$mysql_insert = mysql_query($insert, $mysql_link)
or die("Please notify the admin that the script is connecting to the database, but not inserting the information ".mysql_error());
// moves back to the login page
header("Location: ../index.php?id=home&login=error&sid=$id");
}
?>
client/admin/users.php
<? require ("../login_check.php"); ?>
<? include ("../config.php"); ?>
<? include ("login_check_admin.php"); ?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>Admin Section</title>
<link rel="STYLESHEET" type="text/css" href="../css.css">
<script LANGUAGE="JavaScript">
<!--
function confirmSubmit()
{
var agree=confirm("Are you sure you wish to continue?");
if (agree)
return true ;
else
return false ;
}
// -->
</script>
</head>
<body marginheight="0" marginwidth="0" topmargin="0" leftmargin="0">
<br>
<table class="sitewidth" align="center" valign="top" cellspacing="0" cellpadding="0" border="0">
<tr>
<td valign="bottom" align="left" width="200">
<div class="title" align="left">
<? print "$version"; ?>
</div>
</td>
<td valign="bottom" align="right">
<div align="right">
[ <a href="../index.php">Home</a> ] [ <a href="index.php">Admin Home</a> ]
</div>
</td>
<td valign="bottom" align="right" width="120">
<div align="right">
<strong>Username:</strong> <? print "$valid_user";?><br>
<strong>Security Level:</strong> <? print "$seclevel";?>
</div>
</td>
</tr>
</table>
<table class="sitewidth" align="center" valign="top" cellspacing="0" cellpadding="0" border="0">
<tr>
<td valign="top" colspan="5" height="4"></td>
</tr>
<tr>
<td class="bgBlueMed" align="left" valign="top" colspan="5" height="4"></td>
</tr>
<tr>
<td valign="top" colspan="5" height="10"></td>
</tr>
<tr>
<td width="170" align="left" valign="top">
<form enctype="multipart/form-data" action="<? $PHP_SELF ?>" method="post">
<strong>Quick Add:</strong><br>
Username:<br>
<input type="text" name="username" class="form"><br>
Password:<br>
<input type="text" name="password" class="admin"><br>
Security Level:<br>
<input type="text" name="securitylevel" class="form"><br>
<div align="right"><input type=submit name="Add" value="Add"></div>
</form>
<form enctype="multipart/form-data" action="<? $PHP_SELF ?>" method="post">
<strong>Quick Delete:</strong><br>
<input type="text" name="username" class="form"><br>
<div align="right"><input type=submit name="Delete" value="Delete"></div>
</form>
<br>
</td>
<td width="10" align="left" valign="top"></td>
<td width="680" align="left" valign="top" colspan="3">
<?
// if any of the entries was checked, this deletes the entry form the database
if (count($del) > 0) {
for ($i=0;$i<count($del);$i++) {
$result[$i] = mysql_query("DELETE FROM users WHERE id = '$del[$i]'");
}
}
//this checks to see of the "Add Submit" button was clicked
if (isset($Add)) {
//this checks the username field for a duplicate name, if so, it displays "Username already exists, choose something else"
$query = "SELECT * FROM users WHERE username = '$username'";
$result = mysql_query ($query);
if (mysql_num_rows($result)) die("That username already exsists, please choose a different name");
//this tries to insert the info to the database
else {
$password = md5($password);
$insert = "INSERT INTO users(username, password, securitylevel) VALUES('$username', '$password)', '$securitylevel')";
$mysql_insert = mysql_query($insert, $mysql_link)
or die("Please notify <a href=\"mailto:$admin_address\">$admin_address</a> that the script is connecting to the database, but not inserting entries");
}
print "<div align=\"center\"><strong>User \"$username\" Added</strong></div>";
}
//this checks to see of the "Delete Submit" button was clicked
if (isset($Delete)) {
$deletequery=mysql_query("DELETE FROM users WHERE username = '$username'");
print "<div align=\"center\"><strong>User \"$username\" Deleted</strong></div>";
}
?>
<form type="post" action="<? $PHP_SELF ?>" onSubmit="return confirmSubmit()">
<?
print "<table cellspacing=\"0\" cellpadding=\"1\" align=\"left\">";
print "<tr>
<td></td>
<td><div align=\"center\">ID</div></td>
<td><div align=\"center\">Security</div></td>
<td>Username</td>
<td>Password</td>
<td>Email</td>
<td><div align=\"center\">ID</div></td>
</tr>
";
// this query shows everything (except comments) from the login table
$users_display = mysql_query("SELECT * FROM users") or die (mysql_error());
while ($row = mysql_fetch_array($users_display)) {
// this makes the rows different colors
if ($bgcolor == "#D5D5D5") {
$bgcolor = "#EFEFEF";
} else {
$bgcolor = "#D5D5D5";
}
print "<tr bgcolor=\"$bgcolor\">\n";
print "<td><div align=\"center\">";
print "<a href=\"users_edit.php?rowid=$row[id]\">Edit</a>";
print "</div></td>\n";
print "<td><div align=\"center\">";
echo $row["id"];
print "</div></td>\n";
print "<td><div align=\"center\">";
echo $row["securitylevel"];
print "</div></td>\n";
print "<td>";
echo $row["username"];
print "</td>\n";
print "<td>";
echo $row["password"];
print "</td>\n";
print "<td>";
echo $row["email"];
print "</td>";
print "<td><div align=\"center\">";
print "<input type=\"checkbox\" name=\"del[]\" value=\"";
echo $row["id"];
print "\" class=\"checkbox\">";
print "</div></td>\n";
print " </tr>";
}
mysql_free_result($users_display);
?>
<tr>
<td colspan="7"><div align="right"><input type="submit" name="deletechecked" value="Delete Checked"></div></td>
</tr>
</table>
</form>