コード例 #1
0
<?php

session_start();
$homeURL = 'http://localhost:8888/frontpagevancouver';
include "includes/connection.php";
// if page requested by submitting login form
if (isset($_REQUEST["email"]) && isset($_REQUEST["password"])) {
    $user_exist = get_user_by_email_and_password($_REQUEST["email"], $_REQUEST["password"]);
    // user exist?
    if ($user_exist) {
        // set the user as connected and redirect him to a home page or something
        //$_SESSION["user_connected"] = true;
        header("Location: http://www.example.com/user/home.php");
    } else {
        // redirect him to an error page
        header("Location: http://www.example.com/login-error.php");
    }
} elseif (isset($_REQUEST["provider"])) {
    // the selected provider
    $provider_name = $_REQUEST["provider"];
    try {
        // inlcude HybridAuth library
        // change the following paths if necessary
        $config = 'includes/hybridauth/config.php';
        require_once "includes/hybridauth/Hybrid/Auth.php";
        // initialize Hybrid_Auth class with the config file
        $hybridauth = new Hybrid_Auth($config);
        // try to authenticate with the selected provider
        $adapter = $hybridauth->authenticate($provider_name);
        // then grab the user profile
        $user_profile = $adapter->getUserProfile();
コード例 #2
0
    $operation = 'signin';
}
// echo "OPERATION: $operation <br/>";
$email = $_REQUEST["email"];
$password = $_REQUEST["password"];
$firstname = $_REQUEST["firstname"];
$last_name = $_REQUEST["last-name"];
$form_register = null;
$form_login = null;
$provider_user_id = null;
switch ($operation) {
    case "signin":
        // echo "SIGNIN: $operation <br/>";
        if (isset($email) && isset($password)) {
            $link = linkDatabase() or die("Connection error!");
            $user = get_user_by_email_and_password($link, $email, $password);
            if ($user) {
                $_SESSION["user_connected"] = true;
                header("Location: http://www.studddio.com/index.php");
            } else {
                $error_msg = "Wrong nickname, email or password.";
                $form_login = formLogin();
            }
        } else {
            $form_login = formLogin();
        }
        break;
    case "social-sigin":
        $provider = $_REQUEST["provider"];
        if (isset($provider)) {
            try {