비밀번호 재설정 문의
본문
bbs/password_lost2.php 파일에서 if문 통과한 후 이렇게 코드 추가하고
session_start();
$_SESSION['ss_cert_mb_id'] = $mb['mb_id'];
goto_url(G5_HTTPS_BBS_URL . "/password_reset.php");
bbs/password_reset.php 파일을 불러와서 비밀번호 재설정을 하려고 하는데
if(!(isset($_POST['mb_id']) && $_POST['mb_id'] === $ss_cert_mb_id)) { alert("잘못된 접근입니다."); 여기에 자꾸 걸려서 잘못된 접근입니다. 로 출력됩니다. 해당 if문을 지우면 출력은 잘 되는데 비밀번호가 변경되지 않습니다 수정하는법 알려주세요
<?php
include_once('./_common.php');
//include_once(G5_CAPTCHA_PATH.'/captcha.lib.php');
if ($is_member) { alert("이미 로그인중입니다."); goto_url(G5_URL); }
$ss_cert_mb_id = isset($_SESSION['ss_cert_mb_id']) ? trim(get_session('ss_cert_mb_id')) : '';
if(!(isset($_POST['mb_id']) && $_POST['mb_id'] === $ss_cert_mb_id)) { alert("잘못된 접근입니다."); goto_url(G5_URL); }
if($config['cf_cert_find'] != 1) alert("본인인증을 이용하여 아이디/비밀번호 찾기를 할 수 없습니다. 관리자에게 문의 하십시오.");
$g5['title'] = '비밀번호 재설정';
include_once(G5_PATH.'/_head.php');
$action_url = G5_HTTPS_BBS_URL."/password_reset_update.php";
include_once($member_skin_path.'/password_reset.skin.php');
include_once(G5_PATH.'/_tail.php');
답변 2
goto_url(G5_HTTPS_BBS_URL . "/password_reset.php");
goto_url 인데 post 값이 붙을리가 있나요...
form 으로 전송하세요.
*password_lost2.php에서 goto_url()을 사용하지 않고,
자동 제출되는 POST 폼을 생성하여 전송하는 방식이 가장 적절함.
<?php
session_start();
$_SESSION['ss_cert_mb_id'] = $mb['mb_id']; // 세션에 사용자 ID 저장
?>
<!DOCTYPE html>
<html lang="ko">
<head>
<meta charset="UTF-8">
<title>비밀번호 재설정 이동</title>
</head>
<body>
<form id="passwordResetForm" action="<?= G5_HTTPS_BBS_URL ?>/password_reset.php" method="post">
<input type="hidden" name="mb_id" value="<?= htmlspecialchars($mb['mb_id'], ENT_QUOTES, 'UTF-8') ?>">
</form>
<script>
document.getElementById("passwordResetForm").submit(); // 자동 제출
</script>
</body>
</html>
*password_reset.php에서 세션과 POST 데이터를 활용하여 인증을 처리하도록 수정.
<?php
session_start();
include_once('./_common.php');
if ($is_member) {
alert("이미 로그인중입니다.");
goto_url(G5_URL);
}
// 세션과 POST 값을 이용한 검증
$ss_cert_mb_id = isset($_SESSION['ss_cert_mb_id']) ? trim($_SESSION['ss_cert_mb_id']) : '';
$mb_id = isset($_POST['mb_id']) ? trim($_POST['mb_id']) : '';
if ($mb_id !== $ss_cert_mb_id) {
alert("잘못된 접근입니다.");
goto_url(G5_URL);
}
if ($config['cf_cert_find'] != 1) {
alert("본인인증을 이용하여 아이디/비밀번호 찾기를 할 수 없습니다. 관리자에게 문의하십시오.");
}
$g5['title'] = '비밀번호 재설정';
include_once(G5_PATH.'/_head.php');
$action_url = G5_HTTPS_BBS_URL."/password_reset_update.php";
include_once($member_skin_path.'/password_reset.skin.php');
include_once(G5_PATH.'/_tail.php');
?>