Forum Moderators: coopster
//Check whether the session variable SESS_MEMBER_ID is present or not
if(!isset($_SESSION['SESS_MEMBER_ID']) ¦¦ (trim($_SESSION['SESS_MEMBER_ID']) == '')) {
header("location: access-denied.php");
exit();
}
?>
$sql="SELECT * FROM members WHERE member_id AND count";
//echo print_r($sql);
$query=mysql_query($sql);
$executor=@mysql_fetch_array($query);
/* After being able to see the sql and compare it to the db information, let's see exactly what's stored in the $result array. */
echo print_r($executor);
// Then let's exit until we know this part of the script works correctly.
//exit();
}
if($executor['count']>=3) {
echo "Error";
exit();
}
//exit();
else {
$sql2="UPDATE members SET count=count+1 WHERE 'member_id' " ;
mysql_query($sql2); }
?>
<?php
session_start();
include ("connect.php");if (isset($_POST["login"]))
{
$user = trim(stripslashes($_POST["Username"]));
$passwd = md5($_POST["Password"]);$sql = "SELECT userID, Userlvl FROM users WHERE Username= '%s' AND Password = '%s'";
$result = mssql_query( sprintf( $sql, $user, $passwd ) );
$exist = mssql_num_rows($result);if ($exist > 0)
{
$userID = mssql_result($result,0,"userID");
$userlvl = mssql_result($result,0,"Userlvl");$_SESSION["UID"] = $userID;
$_SESSION["LEVEL"] = $userlvl;if ((isset($_SESSION["UID"])) && ($_SESSION["UID"] != ''))
{
if ($_SESSION["LEVEL"] == 1)
{
echo '<script type="text/javascript">
location.href="";
</script>';
}
else
{
echo '<script type="text/javascript">
location.href="";
</script>';
}
}
else
{
echo '<script type="text/javascript">
alert("Unable to set a session! Please try again...");
history.go(-1);
</script>';
}
}
else
{
echo '<script type="text/javascript">
alert("Invalid Password or Username!");
history.go(-1);
</script>';
}
}
else
{
echo '<script type="text/javascript">
alert("Direct Access not allowed!");
history.go(-1);
</script>';
}?>
user logs..
if (!$sql) die();
$f = @fopen('logs.txt', 'a+');
if ($f) {
@fputs($f, date("m.d.Y g:ia")." ".$_SERVER['REMOTE_ADDR']." ".$Username." ".$_SESSION['SESS_MEMBER_ID']." \n");
@fclose($f);
}
$sql="SELECT * FROM members WHERE member_id = ".$_SESSION['SESS_MEMBER_ID']; // I don't think you really need the " AND count " part
and:
$sql2="UPDATE members SET count=count+1 WHERE member_id = ".$_SESSION['SESS_MEMBER_ID'];
This should work as long as member_id contains numeric values, otherwise you'll need to enclose the right part of the comparisons in single-quotes.