commit
This commit is contained in:
68
kngil/bbs/login.php
Normal file
68
kngil/bbs/login.php
Normal file
@@ -0,0 +1,68 @@
|
||||
<?php
|
||||
session_start();
|
||||
require_once $_SERVER['DOCUMENT_ROOT'].'/kngil/bbs/db_conn.php';
|
||||
|
||||
$input = json_decode(file_get_contents('php://input'), true);
|
||||
$id = trim($input['id'] ?? '');
|
||||
$pw = trim($input['pw'] ?? '');
|
||||
|
||||
if ($id === '' || $pw === '') {
|
||||
echo json_encode([
|
||||
'status' => 'error',
|
||||
'message' => '아이디와 비밀번호를 입력하세요.'
|
||||
]);
|
||||
exit;
|
||||
}
|
||||
|
||||
$stmt = $pdo->prepare("
|
||||
SELECT
|
||||
u.member_id,
|
||||
u.user_id,
|
||||
u.user_pw,
|
||||
u.user_nm,
|
||||
u.auth_bc,
|
||||
u.dept_nm,
|
||||
m.co_nm,
|
||||
u.tel_no,
|
||||
u.email
|
||||
FROM kngil.users u
|
||||
LEFT JOIN kngil.members m
|
||||
ON u.member_id = m.member_id
|
||||
WHERE LOWER(u.user_id) = LOWER(:id)
|
||||
AND u.use_yn = 'Y'
|
||||
LIMIT 1
|
||||
");
|
||||
$stmt->execute([':id' => $id]);
|
||||
|
||||
$user = $stmt->fetch(PDO::FETCH_ASSOC);
|
||||
|
||||
if (!$user) {
|
||||
echo json_encode([
|
||||
'status' => 'error',
|
||||
'message' => '존재하지 않는 아이디입니다.'
|
||||
]);
|
||||
exit;
|
||||
}
|
||||
|
||||
// 현재 구조상 평문 비교
|
||||
if ($user['user_pw'] !== $pw) {
|
||||
echo json_encode([
|
||||
'status' => 'error',
|
||||
'message' => '비밀번호가 올바르지 않습니다.'
|
||||
]);
|
||||
exit;
|
||||
}
|
||||
|
||||
// ✅ 로그인 성공
|
||||
$_SESSION['login'] = [
|
||||
'member_id' => $user['member_id'],
|
||||
'user_id' => $user['user_id'],
|
||||
'user_nm' => $user['user_nm'],
|
||||
'auth_bc' => $user['auth_bc'],
|
||||
'co_nm' => $user['co_nm'] ?? null,
|
||||
'dept_nm' => $user['dept_nm'] ?? null,
|
||||
'tel_no' => $user['tel_no'] ?? null,
|
||||
'email' => $user['email'] ?? null
|
||||
];
|
||||
|
||||
echo json_encode(['status' => 'success']);
|
||||
Reference in New Issue
Block a user