Re-LogIn";
} else if (isset($_REQUEST['logout'])) {
/* * ************************ Step 2 - Case 1 ************************ */
//Log out and redirect login page
unset($_SESSION['admname']);
header('Location: index.php');
} else if (isset($_REQUEST['dashboard'])) {
/* * ************************ Step 2 - Case 2 ************************ */
//redirect to dashboard
header('Location: admwelcome.php');
} else if (isset($_REQUEST['delete'])) {
/* * ************************ Step 2 - Case 3 ************************ */
//deleting the selected test conductors
unset($_REQUEST['delete']);
$hasvar = false;
foreach ($_REQUEST as $variable) {
if (is_numeric($variable)) { //it is because, some session values are also passed with request
$hasvar = true;
if (!@executeQuery("delete from testconductor where tcid=$variable")){
if (mysql_errno () == 1451) //Children are dependent value
$_GLOBALS['message'] = "Too Prevent accidental deletions, system will not allow propagated deletions.
Help: If you still want to delete this user, then first manually delete all the records that are associated with this user.";
else
$_GLOBALS['message'] = mysql_errno();
}
// $_GLOBALS['message']=$_GLOBALS['message'].$variable;
}
}
if (!isset($_GLOBALS['message']) && $hasvar == true)
$_GLOBALS['message'] = "Selected Test Conductor/s are successfully Deleted";
else if (!$hasvar) {
$_GLOBALS['message'] = "First Select the Test Conductors to be Deleted.";
}
} else if (isset($_REQUEST['savem'])) {
/* * ************************ Step 2 - Case 4 ************************ */
//updating the modified values
if (empty($_REQUEST['cname']) || empty($_REQUEST['password']) || empty($_REQUEST['email'])) {
$_GLOBALS['message'] = "Some of the required Fields are Empty.Therefore Nothing is Updated";
} else {
$query = "update testconductor set tcname='" . htmlspecialchars($_REQUEST['cname'],ENT_QUOTES) . "', tcpassword=ENCODE('" . htmlspecialchars($_REQUEST['password'],ENT_QUOTES) . "','oespass'),emailid='" . htmlspecialchars($_REQUEST['email'],ENT_QUOTES) . "',contactno='" . htmlspecialchars($_REQUEST['contactno'],ENT_QUOTES) . "',address='" .htmlspecialchars($_REQUEST['address'],ENT_QUOTES) . "',city='" . htmlspecialchars($_REQUEST['city'],ENT_QUOTES) . "',pincode='" . htmlspecialchars($_REQUEST['pin'],ENT_QUOTES) . "' where tcid='" . $_REQUEST['tc'] . "';";
if (!@executeQuery($query))
$_GLOBALS['message'] = mysql_error();
else
$_GLOBALS['message'] = "Test Conductor Information is Successfully Updated.";
}
closedb();
}
else if (isset($_REQUEST['savea'])) {
/* * ************************ Step 2 - Case 5 ************************ */
//Add the new test conductor information in the database
$result = executeQuery("select max(tcid) as tc from testconductor");
$r = mysql_fetch_array($result);
if (is_null($r['tc']))
$newstd = 1;
else
$newstd=$r['tc'] + 1;
$result = executeQuery("select tcname as tc from testconductor where tcname='" . htmlspecialchars($_REQUEST['cname'],ENT_QUOTES) . "';");
if (empty($_REQUEST['cname']) || empty($_REQUEST['password']) || empty($_REQUEST['email'])) {
$_GLOBALS['message'] = "Some of the required Fields are Empty";
} else if (mysql_num_rows($result) > 0) {
$_GLOBALS['message'] = "Sorry User Already Exists.";
} else {
$query = "insert into testconductor values($newstd,'" . htmlspecialchars($_REQUEST['cname'],ENT_QUOTES) . "',ENCODE('" . htmlspecialchars($_REQUEST['password'],ENT_QUOTES) . "','oespass'),'" . htmlspecialchars($_REQUEST['email'],ENT_QUOTES) . "','" . htmlspecialchars($_REQUEST['contactno'],ENT_QUOTES) . "','" . htmlspecialchars($_REQUEST['address'],ENT_QUOTES) . "','" . htmlspecialchars($_REQUEST['city'],ENT_QUOTES) . "','" . htmlspecialchars($_REQUEST['pin'],ENT_QUOTES) . "')";
if (!@executeQuery($query)) {
if(mysql_errno ()==1062) //duplicate value
$_GLOBALS['message'] = "Given Test Conductor Name voilates some constraints, please try with some other name.";
else
$_GLOBALS['message'] = mysql_error();
}
else
$_GLOBALS['message'] = "Successfully New Test Conductor is Created.";
}
closedb();
}
?>
