kindly help me out in which part where is my error i m not able to find it my code is pasted below i m getting the error 1
Code: Select all
<?php
require_once ("../../../../libs/classes/DB.php");
require_once ("../../../../libs/classes/MyMethods.php");
require_once ("../../../../libs/classes/icons.php");
$db = new DB(); $method = new MyMethods();$icon = new ICON();
if ($method->isOk($_POST['name']) && $method->isOk($_POST['userid'])
&& $method->isOk($_POST['userkey']) && $method->isOk($_POST['role']) & $method->isOk($_POST['Department'])) {
$name= $_POST['name'];
$role = $_POST['role'];
$userid = $_POST['userid'];
$userkey = $_POST['userkey'];
$userkey = $method->make_hash($userkey);
$Department = $_POST['Department'];
//search the same user id if available do not save
$inputVars = array(
':userid' => $userid,
);
/* Saad Code */
$SaadCode = array();
$SaadString = '';
$SaadRole = '';
$SaadRole1 = '';
foreach($db->getRecordSet("SELECT userid,Department,role FROM login WHERE userid ='$userid' ")
as $row)
{
if ($SaadRole <> $role)
{
echo $SaadRole;
echo "Im Here";
$SaadString = $row['Department'];
$SaadRole = $row['role'];
}
}
echo $role;
echo $SaadRole1;
if ( empty($SaadString))
{
$inputsVars = array(
':userid' => $userid,
':userkey' => $userkey,
':role' => $role,
':user_status' => '1',
':name' => $name,
':Department' => $Department
);
$sqlInsert = "INSERT INTO login(
userid,
userkey,
role,
user_status,
Discription,
Department
)
VALUES (
:userid,
:userkey,
:role,
:user_status,
:name,
:Department
)";
if($db->dbQuery($sqlInsert, $inputsVars))
{
echo($method->sucMsg("Information: -", "User saved successfully"));
}
else
{
echo($method->errorMsg("Error: -", "User not saved due to server internel error 1"));
}
}
elseif ($Department <> $SaadString )
{
echo($method->errorMsg("Error", "Username/email already ID already exists"));
}
elseif ($role == $SaadRole)
{
echo($method->errorMsg("Error", "Role already assigned to this ID"));
}
else
{
$inputsVars = array(
':userid' => $userid,
':userkey' => $userkey,
':role' => $role,
':user_status' => '1',
':name' => $name,
':Department' => $Department
);
$sqlInsert = "INSERT INTO login(
userid,
userkey,
role,
user_status,
Discription,
Department
)
VALUES (
:userid,
:userkey,
:role,
:user_status,
:name,
:Department
)";
if($db->dbQuery($sqlInsert, $inputsVars)){
echo($method->sucMsg("Information: -", "User saved successfully"));
} else
{
echo($method->errorMsg("Error: -", "User not saved due to server internal error 2"));
}
}
}
else {
echo($method->errorMsg("Error: -", "Empty fields are not allowed"));
}
/* Saad Code Ends Here */
?>