示例#1
0
require_once 'includes/db.php';
require_once 'includes/users.php';
$errors = array();
$username = filter_input(INPUT_POST, 'username', FILTER_SANITIZE_STRING);
$password = filter_input(INPUT_POST, 'password', FILTER_UNSAFE_RAW);
if ($_SERVER['REQUEST_METHOD'] == 'POST') {
    if (empty($username)) {
        $errors['username'] = true;
    }
    if (empty($password)) {
        $errors['password'] = true;
    }
    if (empty($errors)) {
        $user_id = user_get($db, $username, $password);
        if ($user_id) {
            user_sign_in($user_id);
            // redirect back to the page they came from
            header('location: ' . $_SESSION['referrer']);
            exit;
        } else {
            $errors['no-user'] = true;
        }
    }
}
?>
<!DOCTYPE HTML>
<html>
	<head>
		<meta charset="utf-8">
		<title>Sign in</title>
	</head>
示例#2
0
        $incoming_data = json_decode($programIn, TRUE);
    }
    $action = $_GET['action'];
} else {
    $programIn = file_get_contents('php://input');
    $incoming_data = json_decode($programIn, TRUE);
    $action = $incoming_data['action'];
}
$outgoing_data = array();
switch ($action) {
    case 'update':
    case 'update_asm':
        $outgoing_data = get_update_info();
        break;
    case 'sign_in':
        $outgoing_data = user_sign_in($incoming_data);
        break;
    case 'cache_data':
        $outgoing_data = get_cached_data($incoming_data);
        break;
        // case 'memory_game_list':
        // 	$outgoing_data = get_memory_game_list($incoming_data);
        // 	break;
        // case 'test':
        // 	$outgoing_data['foo'] = 'bar';
        // 	break;
    // case 'memory_game_list':
    // 	$outgoing_data = get_memory_game_list($incoming_data);
    // 	break;
    // case 'test':
    // 	$outgoing_data['foo'] = 'bar';
<!DOCTYPE html>
<!--
To change this license header, choose License Headers in Project Properties.
To change this template file, choose Tools | Templates
and open the template in the editor.
-->
<html>
    <head>
        <meta charset="UTF-8">
        <title></title>
    </head>
    <body>
        
        <?php 
//        echo $_POST['user_email'];
//        echo md5($_POST['user_password']);
$connection = connect_to_mysql();
$row = user_sign_in($connection);
if ($row) {
    $_SESSION['id'] = $row['id'];
    $_SESSION['email'] = $row['email'];
    $_SESSION['admin'] = $row['admin'];
    echo "<br>You're logged in!!!!";
}
header("Location: index.php");
exit;
?>
    </body>
</html>