I have come with my own way to build up a system log feature for admins. It is storing some information to a separate. But i have some problems to how to execute those two queries @ the same time.
this is my add_user_save.php page
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title></title>
</head>
<body>
<div align="right"> you are logged as <?php echo $_SESSION['SESS_LOGIN'];?> |<a href="adduser.php"> Add another user</a> | <a href="member-index.php"> Home </a> | <a href="logout.php">Logout </a> </div>
<?php
if(!isset($_SESSION['SESS_LOGIN']) || $_SESSION['SESS_TYPE'] !='admin')
{
echo '<script language="javascript">';
echo 'alert("Please login as ADMINISTRATOR to add a user");';
echo ' window.location.replace("index.html");';
echo '</script>';
}
else
{
include("config.php");
$login = mysql_real_escape_string($_POST['login']);
$password = mysql_real_escape_string($_POST['password']);
$type = mysql_real_escape_string($_POST['type']);
$email = mysql_real_escape_string($_POST['email']);
$password = md5($password);
$qry_add = " INSERT INTO members
(login, password, type, email )
VALUES ('$login', '$password', '$type', '$email') ";
$sql_log = " INSERT INTO system_log (Entry_Date, login, Activity, Description )
VALUES (NOW(), '".$_SESSION["SESS_LOGIN"]."', 'ADD USER', '$login')";
$checkformembers = mysql_query("SELECT * FROM members WHERE login='$login'");
if(mysql_num_rows($checkformembers) != 0)
{
echo "<font color=red> Duplicate Entry. Please Verify User name !</font>";
}
else
{
$result=mysql_query($qry_add);
$result1=mysql_query($qry_log);
if (($result !=0) && ($result1!=0))
//if ($result)
{
echo "<br><font color=green size=+1 >you have successfully added new user ! </font> " ;
}
else
{
echo "<br><font color=red size=+1 >Problem in Adding !</font><br>" ;
echo "ERROR - unable to save new username and password!<br>";
$SQLError = "SQL ERROR: ".mysql_errno().". ".mysql_error()."<BR><BR>";
echo "$SQLError";
mysql_close();
}
}
}
?>
</body>
</html>
this is the error i got >> SQL ERROR: 1065. Query was empty