Exemple #1
0
function attempt_login($username, $password)
{
    $regd_user = find_user_by_username($username);
    if ($regd_user) {
        if (check_password($password, $regd_user['hashed_password'])) {
            return $regd_user;
        } else {
            return false;
        }
    } else {
        return false;
    }
}
Exemple #2
0
function attempt_login($username, $password, $email)
{
    $user_set = find_user_by_username($username, $email);
    if (password_verify($password, $user_set["hashed_password"])) {
        $_SESSION["name"] = $user_set["username"];
        $_SESSION["mail"] = $user_set["email"];
        $_SESSION["user_type"] = $user_set["user_type"];
        $_SESSION["user_status"] = $user_set["user_status"];
        $_SESSION["user_id"] = $user_set["user_id"];
        return $user_set;
    } else {
        $_SESSION["error_msg"] = "Username/Password/Email Not Found <br>";
        return false;
    }
}
Exemple #3
0
function attempt_login($username, $password)
{
    $admin = find_user_by_username($username);
    if ($admin) {
        if (password_check($password, $admin)) {
            return $admin;
        } else {
            echo "<div id=\"error\">";
            echo " password does not match";
            echo "</div>";
            return false;
        }
    } else {
        // user not found
        return false;
    }
}
Exemple #4
0
function attempt_login($username, $password)
{
    $find_user = find_user_by_username($username);
    $user = $find_user[0];
    if (isset($user)) {
        if (password_check($password, $user['password'])) {
            // password matches
            return $user;
        } else {
            // password does not match
            return false;
        }
    } else {
        // user not found
        return false;
    }
}
function attempt_login($username, $password)
{
    //find user, then password
    $user = find_user_by_username($username);
    if ($user) {
        //found admin, check password
        if (password_verify($password, $user["hashed_password"])) {
            //password matches
            return $user;
        } else {
            //password doesn't match
            echo "bad password<br>";
            return false;
        }
    } else {
        //not found
        return false;
    }
}
Exemple #6
0
function attempt_login($username, $pword)
{
    //echo 'attempt_login ' . $password . ' — ' . $username . '<br/>';
    //var_dump($password);
    //hash password
    $password = crypt($pword, CRYPT_BLOWFISH);
    $find_user = find_user_by_username($username);
    $user = $find_user[0];
    //echo '<br/><br/>$user: '******'<br/>password_check called';
        if (password_check($password, $user['password'])) {
            // password matches
            return $user;
        } else {
            // password does not match
            return false;
        }
    } else {
        // user not found
        return false;
    }
}
function attempt_login_user($username, $password)
{
    $user = find_user_by_username($username);
    if ($user) {
        if (password_check($password, $user["hashed_password"])) {
            return $user;
        } else {
            return false;
        }
    } else {
        return false;
    }
}
Exemple #8
0
<?php

require_once "../../includes/session.php";
require_once "../../includes/db_connection.php";
require_once "../../includes/functions.php";
require_once "../../includes/validation_functions.php";
confirm_logged_in();
$current_user = $_SESSION["username"];
$name_query = "SELECT * FROM users WHERE username = '******' LIMIT 1";
$name_result = mysqli_query($conn, $name_query);
confirm_query($name_result);
$name_title = mysqli_fetch_assoc($name_result);
$first_name = explode(" ", $name_title['sname']);
$user = find_user_by_username($_SESSION["username"]);
if (!$user) {
    redirect_to("buzz.php");
}
$default_branch = "CSE ECE ME EEE CIVIL";
$default_club = "Dance Drama Android Linux Music";
$sent1 = $default_branch . " " . $default_club;
$sent2 = $name_title['filter_branch'] . " " . $name_title['filter_club'];
$out = explode(" ", $sent1);
$size_array = sizeof($out);
$tobeDisplayed = new SplFixedArray($size_array);
for ($m = 0; $m < $size_array; $m++) {
    $sry = array("{$out[$m]} {$sent2}");
    $temp = $out[$m];
    $n2 = strlen($temp);
    $s = implode(" ", $sry);
    $n = strlen($s);
    $Z = new SplFixedArray($n);
Exemple #9
0
/**
 * This will attempt login with given credentials 
 * @param  password & email as entered by user on form
 */
function attempt_login($username, $password)
{
    $user = find_user_by_username($username);
    if ($user) {
        // found admin, now check password
        if (password_check($password, $user["hashed_password"])) {
            // password matches
            return $user;
        } else {
            // password does not match
            return false;
        }
    } else {
        // admin not found
        return false;
    }
}
function init_user_avatar($username)
{
    global $connection;
    $user_id = find_user_by_username($username)["id"];
    $query = "INSERT INTO avatars ( ";
    $query .= "user_id ";
    $query .= ") VALUES ( ";
    $query .= " {$user_id} ";
    $query .= " ) ";
    $result = mysqli_query($connection, $query);
    if (!$result) {
        echo "Avatar not initalized. ";
    }
}
Exemple #11
0
require_once "../../includes/db_connect.php";
require_once "../../includes/functions.php";
require_once "../../includes/validations_functions.php";
include "../../includes/layouts/page_header.php";
logged_in();
?>

<?php 
if (isset($_POST['submit'])) {
    $username = mysqli_prep($_POST["username"]);
    $password = password_encrypt($_POST["password"]);
    $required_fields = array("username", "password");
    validate_presences($required_fields);
    $field_with_max_lengths = array("username" => 60);
    validate_max_lengths($field_with_max_lengths);
    if (find_user_by_username($username)) {
        $_SESSION["message"] = "Username already taken!!!";
        redirect_to("manage_users.php");
    }
    if (empty($errors)) {
        $ins_query = "INSERT INTO users (";
        $ins_query .= "username, hashed_password";
        $ins_query .= ") VALUES (";
        $ins_query .= "'{$username}','{$password}'";
        $ins_query .= ");";
        $result = mysqli_query($connection, $ins_query);
        if ($result && mysqli_affected_rows($connection) == 1) {
            $_SESSION["message"] = "User creation success.";
            redirect_to("manage_users.php");
        } else {
            $_SESSION["message"] = "User creation failed.";