예제 #1
0
function see_all_holidays()
{
    $db = new adb();
    $db->connect();
    $sql = "SELECT h_id, h_name, DATE_FORMAT(h_date, '%d %b %Y') as h_dates\n        \t\tFROM lms_holidays\n        \t\tWHERE h_date >= CURDATE()\n        \t\tORDER BY h_date";
    $result = mysql_query($sql);
    //run the query
    if ($result === FALSE) {
        die(mysql_error());
        // TODO: better error handling
    }
    if (mysql_num_rows($result) > 0) {
        echo "<table class='table table-striped'>";
        echo "<thead><tr>";
        echo "<th>HOLIDAY</th>";
        echo "<th>DATE</th>";
        echo "</tr></thead>";
        echo "<tbody>";
        while ($row = mysql_fetch_array($result)) {
            echo "<tr>";
            echo "<td>" . $row['h_name'] . "</td>";
            echo "<td>" . $row['h_dates'] . "</td>";
            echo "</tr>";
        }
        echo "</tbody>\n\t\t\t</table>";
        mysql_free_result($result);
    } else {
        echo "<center><div align='center' class='alert alert-danger' role='alert'>\n        \t<i class='glyphicon glyphicon-alert'></i><b>No Holidays Recorded In The System</b></div></center>";
    }
}
예제 #2
0
        if (!$this->connect()) {
            return false;
        }
        $this->result = mysql_query($str_sql);
        if (!$this->result) {
            $this->log_error(LOG_LEVEL_DB_FAIL, 4, "query failed", mysql_error($this->link));
            return false;
        }
        return true;
    }
    /**
     * returns number of rows in current dataset
     */
    function get_num_rows()
    {
        return mysql_num_rows($this->result);
    }
    /**
     *returns last auto generated id 
     */
    function get_insert_id()
    {
        return mysql_insert_id($this->link);
    }
}
$obj = new adb();
if ($obj->connect()) {
    //echo "connected";
} else {
    echo "not connected";
}
						<span style = 'padding:1%' class="menuitem1" ><a href='addTask.php'style="text-decoration:none;color:#42433c">Add task</a></span>
						<span style='float:right' ><input  type="text" placeholder = "Search" id="txtSearch" />
						<span><input type="submit" name="button" value="Go"></span>		
						</span>		
					</div>
					<div id="divStatus" class="status">
						status message
					</div>
					<div id="divContent">
						Content space
						<span class="clickspot">click here </span>
				
						<?php 
include 'adb.php';
$obj = new adb();
$obj->connect();
$select_query = "Select * from task,nurse where task.nurse_id = nurse.nurse_id";
$obj->query($select_query);
echo "<table border='1' id='tableExample' class='reportTable' width='100%'>";
echo "<tr style = 'Background-color:#066d5d' class='header'>";
echo "<td>Task id</td>";
echo "<td>Task name</td>";
echo "<td>Due date</td>";
echo "<td>Description</td>";
echo "<td>Nurse</td>";
echo "<td></td>";
echo "<td></td>";
echo "</tr>";
$row = $obj->fetch();
while ($row) {
    echo "<tr>";
function login()
{
    $username = trim(htmlentities($_REQUEST["username"]));
    $password = trim(htmlentities($_REQUEST["password"]));
    $pass = md5($password);
    $salt = md5("datamanagement");
    $pepper = "ikyhtgtbhfdsfsqwnk";
    $thePass = $salt . $pass . $pepper;
    $db = new adb();
    $db->connect();
    $query = "SELECT * FROM ge_users \n\t\t\t\t\tINNER JOIN ge_departments ON (ge_users.u_department = ge_departments.d_id)\n\t\t\t\t\tINNER JOIN ge_groups ON (ge_users.u_group = ge_groups.g_id)\n\t\t\t\t\tWHERE username='******' AND password=MD5('{$password}')";
    $result = mysql_query($query) or die(mysql_error());
    $num_rows = mysql_num_rows($result);
    $info = mysql_fetch_assoc($result);
    //echo "Got result";
    if ($result) {
        if ($num_rows > 0) {
            if ($info['u_group'] == 1) {
                $dep = $info['d_name'];
                $r_dep = str_replace(' ', '_', $dep);
                session_start();
                $_SESSION['login'] = "******";
                $_SESSION['u_id'] = $info["u_id"];
                $_SESSION['firstname'] = $info["firstname"];
                $_SESSION['lastname'] = $info["lastname"];
                $_SESSION['username'] = $info["username"];
                $_SESSION['u_group'] = $info["u_group"];
                $_SESSION['u_department'] = $info["u_department"];
                header("Location: 1_ce/");
            } else {
                if ($info['u_group'] == 2) {
                    $dep = $info['d_name'];
                    $r_dep = str_replace(' ', '_', $dep);
                    session_start();
                    $_SESSION['login'] = "******";
                    $_SESSION['u_id'] = $info["u_id"];
                    $_SESSION['firstname'] = $info["firstname"];
                    $_SESSION['lastname'] = $info["lastname"];
                    $_SESSION['username'] = $info["username"];
                    $_SESSION['u_group'] = $info["u_group"];
                    $_SESSION['u_department'] = $info["u_department"];
                    header("Location: 2_director/dep_" . $r_dep . "/");
                } else {
                    if ($info['u_group'] == 3) {
                        $dep = $info['d_name'];
                        $r_dep = str_replace(' ', '_', $dep);
                        session_start();
                        $_SESSION['login'] = "******";
                        $_SESSION['u_id'] = $info["u_id"];
                        $_SESSION['firstname'] = $info["firstname"];
                        $_SESSION['lastname'] = $info["lastname"];
                        $_SESSION['username'] = $info["username"];
                        $_SESSION['u_group'] = $info["u_group"];
                        $_SESSION['u_department'] = $info["u_department"];
                        header("Location: 3_manager/dep_" . $dep . "/");
                    } else {
                        if ($info['u_group'] == 4) {
                            $dep = $info['d_name'];
                            $r_dep = str_replace(' ', '_', $dep);
                            session_start();
                            $_SESSION['login'] = "******";
                            $_SESSION['u_id'] = $info["u_id"];
                            $_SESSION['firstname'] = $info["firstname"];
                            $_SESSION['lastname'] = $info["lastname"];
                            $_SESSION['username'] = $info["username"];
                            $_SESSION['u_group'] = $info["u_group"];
                            $_SESSION['u_department'] = $info["u_department"];
                            header("Location: 4_regular/dep_" . $r_dep . "/");
                        }
                    }
                }
            }
        } else {
            ?>
				<script>
					alert("Invalid Username or Password!");
			      	window.history.back();
				</script>
				<?php 
            // $msg="username or password is incorrect";
        }
    } else {
        ?>
				<script>
					alert("Invalid Username or Password");
			      window.history.back();
				</script>
				<?php 
    }
}