티스토리 뷰
/insert_form/insert_form.html
<form id="myCustomForm">
<input type="text" name="title" placeholder="제목" required><br>
<textarea name="content" placeholder="내용" required></textarea><br>
<input type="text" name="nick_name" placeholder="닉네임">
<input type="password" name="password" placeholder="비밀번호">
<button type="button" onclick="submitToRhymix()">등록하기</button>
</form>
<script src="https://code.jquery.com/jquery-3.6.0.min.js"></script>
<script>
// 라이믹스의 자동 CSRF 토큰 할당 기능을 일시적으로 우회
if(typeof jQuery !== 'undefined' && !jQuery.fn.addCSRFTokenToForm) {
jQuery.fn.addCSRFTokenToForm = function() { return this; };
}
function submitToRhymix() {
var formData = jQuery('#myCustomForm').serialize();
console.log("데이터 전송 시작...", formData); // 확인용
$.ajax({
// 알려주신 경로를 절대 경로로 정확히 기입합니다.
url: '/rx/insert_form/insert_proc.php',
type: 'POST',
data: formData,
dataType: 'json',
success: function(response) {
if (response && response.error === 0) {
alert(response.message); // "등록이 완료되었습니다."
location.reload(); // 또는 메인 페이지로 이동: location.href = '/';
} else {
alert('에러: ' + response.message);
}
},
error: function(xhr) {
console.error("에러 상태:", xhr.status);
console.error("응답 내용:", xhr.responseText);
alert('파일을 찾을 수 없습니다(404). 경로가 /rx/insert_form/insert_proc.php 가 맞는지 확인해주세요.');
}
});
}
</script>
/insert_form/insert_proc.php
<?php
// 1. 에러 출력 방지 및 버퍼링 (JSON 응답 오염 방지)
ob_start();
error_reporting(0);
ini_set('display_errors', 0);
define('__XE__', true);
// 2. 라이믹스 로드
require_once('../config/config.inc.php');
$oContext = &Context::getInstance();
$oContext->init();
// 3. 데이터 받기
$title = $_POST['title'] ?? '';
$content = $_POST['content'] ?? '';
$nick_name = $_POST['nick_name'] ?: '비회원';
$password = $_POST['password'] ?: '1111';
$module_srl = 51; // 실제 게시판 모듈 번호에 맞게 수정하세요.
header('Content-Type: application/json');
try {
if(!$title || !$content) throw new Exception('필수 데이터가 누락되었습니다.');
// 4. 비밀번호 암호화 (라이믹스 방식)
$memberModel = getModel('member');
$hash_password = $memberModel->hashPassword($password);
// 5. 문서 번호 및 날짜 생성
$oDB = DB::getInstance();
$document_srl = getNextSequence();
$regdate = date('YmdHis');
// 6. [중요] 정적 HTML 인쇄 파일 생성 로직
$html_save_dir = '../files/saved_html/';
if(!is_dir($html_save_dir)) mkdir($html_save_dir, 0777, true);
$html_filename = "print_{$document_srl}.html";
$html_web_path = '/rx/files/saved_html/' . $html_filename; // 브라우저 접근 경로
$html_full_path = $html_save_dir . $html_filename; // 서버 물리 저장 경로
// 인쇄용 HTML 디자인 구성
$saved_html_content = '
<!DOCTYPE html>
<html lang="ko">
<head>
<meta charset="UTF-8">
<title>접수 확인서 - ' . htmlspecialchars($title) . '</title>
<style>
body { font-family: "Malgun Gothic", sans-serif; color: #333; padding: 50px; line-height: 1.6; }
.receipt-box { border: 2px solid #000; padding: 40px; max-width: 800px; margin: 0 auto; position: relative; }
h1 { text-align: center; text-decoration: underline; margin-bottom: 50px; font-size: 30px; letter-spacing: 5px; }
table { width: 100%; border-collapse: collapse; margin-bottom: 20px; }
th, td { border: 1px solid #000; padding: 12px; text-align: left; }
th { background: #f9f9f9; width: 25%; font-weight: bold; }
.content-area { min-height: 350px; border: 1px solid #000; padding: 20px; margin-top: 10px; white-space: pre-wrap; background: #fff; }
.footer-info { text-align: center; margin-top: 40px; font-weight: bold; font-size: 18px; }
.stamp { position: absolute; bottom: 60px; right: 60px; width: 80px; height: 80px; border: 3px double red; border-radius: 50%; color: red; text-align: center; line-height: 80px; transform: rotate(-15deg); font-weight: bold; }
@media print { .no-print { display: none; } body { padding: 0; } .receipt-box { border: 1px solid #000; } }
</style>
</head>
<body>
<div class="no-print" style="text-align:right; margin-bottom:20px;">
<button onclick="window.print()" style="padding:10px 20px; cursor:pointer;">이 확인서 인쇄/PDF저장</button>
</div>
<div class="receipt-box">
<h1>접 수 확 인 서</h1>
<table>
<tr><th>접수번호</th><td>' . $document_srl . '</td></tr>
<tr><th>접수일자</th><td>' . date('Y-m-d H:i') . '</td></tr>
<tr><th>성 명</th><td>' . htmlspecialchars($nick_name) . '</td></tr>
<tr><th>제 목</th><td>' . htmlspecialchars($title) . '</td></tr>
</table>
<div style="font-weight:bold; margin-top:20px;">[접수 내용]</div>
<div class="content-area">' . nl2br(htmlspecialchars($content)) . '</div>
<div class="footer-info">' . date('Y년 m월 d일') . '<br><br>신한DS 귀중</div>
<div class="stamp">접수확인</div>
</div>
</body>
</html>';
// 파일 물리적 저장
file_put_contents($html_full_path, $saved_html_content);
// 7. [핵심] 본문(content) 하단에 관리자용 인쇄 링크 삽입
$admin_link_tag = '
<br><br><hr>
<div style="padding:15px; background:#f0f7ff; border:1px dashed #007bff; border-radius:5px;">
<p style="margin:0; font-weight:bold; color:#0056b3;">[관리자 전용 기능]</p>
<a href="' . $html_web_path . '" target="_blank" onclick="window.open(this.href, \'_blank\', \'width=950,height=900\'); return false;" style="color:#ff0000; text-decoration:underline; font-size:1.1em;">
▶ 접수확인서 인쇄하기 (정적 HTML 파일 열기)
</a>
<p style="margin:5px 0 0 0; font-size:12px; color:#666;">* 이 링크는 등록 시점의 내용을 고정 보관한 파일로 연결됩니다.</p>
</div>';
$db_content = $content . $admin_link_tag;
// 8. DB 저장
$query = "INSERT INTO documents
(document_srl, module_srl, title, content, user_id, nick_name, password, regdate, last_update, list_order, update_order, comment_status, status)
VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, 'ALLOW', 'SECRET')";
$args = array(
$document_srl, $module_srl, $title, $db_content,
0, $nick_name, $hash_password,
$regdate, $regdate,
$document_srl * -1, $document_srl * -1
);
$stmt = $oDB->prepare($query);
$result = $stmt->execute($args);
if(!$result) throw new Exception('DB 저장 실패');
// 9. 최종 응답
ob_end_clean();
echo json_encode(array(
'error' => 0,
'message' => '등록이 완료되었습니다.',
'document_srl' => $document_srl
));
} catch (Exception $e) {
ob_end_clean();
echo json_encode(array('error' => -1, 'message' => $e->getMessage()));
}'라이믹스' 카테고리의 다른 글
| 라이믹스 후원 입력폼. 동의서 및 양식,서식으로 저장 및 출력 (0) | 2026.03.11 |
|---|---|
| 라이믹스 입력폼. 비밀번호 암호화 (0) | 2026.03.10 |
| 라이믹스 입력폼 (0) | 2026.03.10 |
| 라이믹스 위젯으로만 메인화면 전체를 사용하여 구성하는 방법(백그라운드 색 표현 가능) (0) | 2025.12.09 |
| 라이믹스 슬라이딩 위젯 (0) | 2025.12.09 |
댓글
공지사항
최근에 올라온 글
최근에 달린 댓글
- Total
- Today
- Yesterday
링크
TAG
- 프로씨
- xe addon
- webix
- XE
- 이클립스
- proc
- C언어
- 파이썬
- 라이믹스
- MySQL
- esql
- Python
- 플러터
- 스크래핑
- ocajp
- xe애드온
- 자바
- 오라클
- EC
- 포인터
- C
- XE3
- JDBC
- 파싱
- 문자열
- 자바 smtp
- 인포믹스
- ocjap
- KG
- php
| 일 | 월 | 화 | 수 | 목 | 금 | 토 |
|---|---|---|---|---|---|---|
| 1 | 2 | 3 | 4 | 5 | 6 | 7 |
| 8 | 9 | 10 | 11 | 12 | 13 | 14 |
| 15 | 16 | 17 | 18 | 19 | 20 | 21 |
| 22 | 23 | 24 | 25 | 26 | 27 | 28 |
| 29 | 30 | 31 |
글 보관함

