function sign_in($email, $password)
{
    if ($GLOBALS['$connected'] == False) {
        connect_to_db();
    }
    // Searching the email address in the database
    $result = get_email($email);
    $row = mysql_fetch_array($result);
    $hash = $row["password"];
    //Unhashing the password to see if it matches what was entered.
    if (password_verify($password, $hash)) {
        $id = $row["id"];
        $_SESSION['login_user'] = "******";
        // Initializing Session
        $privilege = get_privilege();
        setcookie("user_id", $id);
        setcookie("user_priv", $privilege);
        //session_id('$id');
        session_start();
        header('Location:index.html');
    } else {
        echo '<script>';
        echo 'alert("Password is invalid");';
        echo 'location.href="index.html"';
        echo '</script>';
    }
}
Beispiel #2
0
    ?>
&action=grantgroup"><?php 
    echo $strAddGroup;
    ?>
</a>
<?php 
} else {
    $i = 0;
    while ($p = $arrPrivileges[$i]) {
        $cb_priv[$p] = '<input type="checkbox" name="privileges[]" value="' . "{$p}\"> " . ucfirst($p) . "</input>";
        $i++;
    }
    $Expected = $strYes;
    $Action = "grant";
    $strToFrom = "to";
    $privileges = get_privilege($table);
    switch ($action) {
        case "revoke":
            $Expected = $strNo;
            $Action = "revoke";
            $strToFrom = "from";
        case "grant":
            $name = rawurldecode($user);
            $i = 0;
            while ($p = $arrPrivileges[$i]) {
                if ($privileges[$name][$p] == $Expected) {
                    unset($cb_priv[$p]);
                }
                $i++;
            }
            $user = "******";