Exemple #1
0
<?php

/**
 * Created by PhpStorm.
 * User: jokerwolf
 * Date: 14/10/15
 * Time: 00:33
 */
require_once $_SERVER['DOCUMENT_ROOT'] . '/server/resources/constants.php';
require_once $_SERVER['DOCUMENT_ROOT'] . '/server/error/index.php';
if (!isset($_POST['login']) || !isset($_POST['pwd'])) {
    errorPage(ERROR_MESSAGE_ENTER_LOGIN_PWD);
    exit;
}
if (accessGranted($_POST['login'], $_POST['pwd'])) {
    homePage();
} else {
    errorPage(ERROR_MESSAGE_WRONG_LOGIN_PWD);
}
function homePage()
{
    header('Location: todo/');
}
function accessGranted($login, $pwd)
{
    return true;
}
} else {
    $servername = "localhost";
    $username = "******";
    $password = "******";
    $dbname = "captajc5_group";
    $conn = new mysqli($servername, $username, $password, $dbname);
    $query = "SELECT * FROM UserInfo";
    $query .= " WHERE username = '******' and password = '******'";
    echo $query;
    $update = "UPDATE UserInfo SET status = 1  WHERE username = '******' and password = '******'";
    $result = $conn->query($query);
    $userVerified = 0;
    if ($result->num_rows > 0) {
        $userVerified = 1;
        $conn->query($update);
        accessGranted($USERNAME, $path);
    } else {
        wrongPassword();
    }
}
function accessGranted($name, $path)
{
    $_SESSION["username"] = $name;
    if (strlen($path) < 12) {
        header("Location: http://www.captainlongxu.com/marketplace/" . $path);
    } else {
        header("Location: http://" . $path);
    }
}
function wrongPassword()
{