65 lines
1.7 KiB
PHP
65 lines
1.7 KiB
PHP
<?php
|
|
require_once(dirname(__DIR__) . "/session.php");
|
|
|
|
$id = $_REQUEST["uid"] ?? '';
|
|
$pw = $_REQUEST["upw"] ?? '';
|
|
|
|
require_once(dirname(__DIR__) . "/lib/mydb.php");
|
|
$pdo = db_connect();
|
|
|
|
try {
|
|
$sql = "select * from chandj.member where id=?";
|
|
$stmh = $pdo->prepare($sql);
|
|
$stmh->bindValue(1, $id, PDO::PARAM_STR);
|
|
$stmh->execute();
|
|
$count = $stmh->rowCount();
|
|
} catch (PDOException $Exception) {
|
|
print "Error: " . $Exception->getMessage();
|
|
exit;
|
|
}
|
|
|
|
$row = $stmh->fetch(PDO::FETCH_ASSOC);
|
|
|
|
if ($count < 1) {
|
|
?>
|
|
<script>
|
|
alert("아이디가 틀립니다!");
|
|
history.back();
|
|
</script>
|
|
<?php
|
|
} elseif ($pw != $row["pass"]) {
|
|
?>
|
|
<script>
|
|
alert("비밀번호가 틀립니다!");
|
|
history.back();
|
|
</script>
|
|
<?php
|
|
} else {
|
|
|
|
// Login Success
|
|
$_SESSION["DB"] = 'chandj';
|
|
$_SESSION["userid"] = $row["id"] ?? '';
|
|
$_SESSION["name"] = $row["name"] ?? '';
|
|
$_SESSION["level"] = $row["lv"] ?? '';
|
|
$_SESSION["division"] = $row["division"] ?? '';
|
|
$_SESSION["mycompany"] = $row["division"] ?? '';
|
|
|
|
// Simple Log
|
|
try {
|
|
$data = date("Y-m-d H:i:s") . " - " . $_SESSION["userid"] . " - " . $_SESSION["name"] . " (Sales Login)";
|
|
// Check if logdata table exists or handle error gracefully if strictly sales context
|
|
// Assuming chandj.logdata exists
|
|
$sql = "insert into chandj.logdata(data) values(?) ";
|
|
$stmh = $pdo->prepare($sql);
|
|
$stmh->bindValue(1, $data, PDO::PARAM_STR);
|
|
$stmh->execute();
|
|
} catch (Throwable $e) {
|
|
// Ignore log error
|
|
}
|
|
|
|
// Redirect to main page
|
|
header("Location: /index.php");
|
|
exit;
|
|
}
|
|
?>
|