<?php
require
'../mysql_connect.php'
;
require
(
'../model/functions.php'
);
include_once
'../views/login.html.php'
;
if
(
$_SERVER
[
'REQUEST_METHOD'
] ==
'POST'
) {
// 处理表单
if
(isset(
$_POST
[
'login_submit'
])) {
$role
=
$_POST
[
'role'
];
$username
=
$_POST
[
'username'
];
$passwd
=
$_POST
[
'p'
];
if
( user_login(
$pdo
,
$role
,
$username
,
$passwd
) ){
setcookie(
'userName'
,
$name
);
setcookie(
'password'
,
$psw
);
header(
"location: index.php"
);