Files
sam-kd/file/file_process.php
hskwon aca1767eb9 초기 커밋: 5130 레거시 시스템
- URL 하드코딩 → .env APP_URL 기반 동적 URL로 변경
- DB 연결 하드코딩 → .env 기반으로 변경
- MySQL strict mode DATE 오류 수정
2025-12-10 20:14:31 +09:00

66 lines
2.0 KiB
PHP

<?php
if(!isset($_SESSION))
session_start();
if(isset($_SESSION["DB"]))
$DB = $_SESSION["DB"] ;
$level= $_SESSION["level"];
$user_name= $_SESSION["name"];
$user_id= $_SESSION["userid"];
if(isset($_REQUEST["num"]))
$num=$_REQUEST["num"];
if(isset($_REQUEST["measureday"]))
$measureday=$_REQUEST["measureday"];
// if($measureday!="0000-00-00" and $measureday!="1970-01-01" and $measureday!="") $measureday = date("Y-m-d", strtotime( $measureday) );
// else
// $measureday=date("Y-m-d");
if(isset($_REQUEST["check"]))
$check=$_REQUEST["check"];
else
$check=$_POST["check"];
require_once($_SERVER['DOCUMENT_ROOT'] . "/lib/mydb.php");
$pdo = db_connect();
try{
$sql = "select * from " . $DB . ".work where num=?";
$stmh = $pdo->prepare($sql);
$stmh->bindValue(1, $num, PDO::PARAM_STR);
$stmh->execute();
$row = $stmh->fetch(PDO::FETCH_ASSOC);
$update_log=$row["update_log"];
}catch (PDOException $Exception) {
print "오류: ".$Exception->getMessage();
}
$data=date("Y-m-d H:i:s") . " - " . $_SESSION["name"] . " " ;
$update_log = $data . $update_log . "&#10"; // 개행문자 Textarea
try{
$pdo->beginTransaction();
$sql = "update " . $DB . ".work set measureday=?, update_log=? where num=? LIMIT 1";
$stmh = $pdo->prepare($sql);
$stmh->bindValue(1, $measureday, PDO::PARAM_STR);
$stmh->bindValue(2, $update_log, PDO::PARAM_STR);
$stmh->bindValue(3, $num, PDO::PARAM_STR); //고유키값이 같나?의 의미로 ?로 num으로 맞춰야 합니다. where 구문
$stmh->execute();
$pdo->commit();
} catch (PDOException $Exception) {
$pdo->rollBack();
print "오류: ".$Exception->getMessage();
}
// echo '<script>alert("실측일이 입력되었습니다."");</script>';
header("Location:https://dh2024.co.kr/p/view.php?num=$num&check=$check");
?>