채택완료

로그인 하면 로그아웃이 나오게 하고싶은데..

2017-12-22 (금) 09:47:26 2,296

로그인 스킨을 사용하지 않고 상단에 아래와 같은 소스를 넣어서 링크 하고 있습니다.

홈으로  로그인  회원가입

Copy
<div class="top-contact pull-right">
<a href="main.php" class="hyper"><i class="fa fa-home"></i> 홈으로</a>
<a href="login.php" class="hyper"><i class="fa fa-sign-in"></i> 로그인</a>
<a href="register.php" class="hyper"><i class="fa fa-unlock" aria-hidden="true"></i> 회원가입</a>
</div>

위에 소스를 로그인 한 경우에

홈으로  로그아웃  정보수정

이렇게 나오게 할려면 소스를 어찌 수정 해야 할까요?

로그인 하기전과 로그인후 멤버 일때 구문으로 나누어서 넣어 줘야 할거같은데..

아시는 분 답변 좀 부탁 드리겠습니다. ^^*

|

답변 2개 / 댓글 5개

채택된 답변
+20 포인트
Copy
<div class="top-contact pull-right">

<a href="main.php" class="hyper"><i class="fa fa-home"></i> 홈으로</a>

<?php if ($is_member) {  ?>

<a href="login.php" class="hyper"><i class="fa fa-sign-in"></i> 로그인</a>
<a href="register.php" class="hyper"><i class="fa fa-unlock" aria-hidden="true"></i> 회원가입</a>

<?php if ($is_admin) {  ?>
<a href="<?php echo G5_ADMIN_URL ?>"><b><i class="fa fa-user-circle" aria-hidden="true"></i> 관리자</b></a>
<?php }  ?>
<?php } else {  ?>

<a href="logout.php" class="hyper"><i class="fa fa-sign-in"></i> 로그아웃</a>
<a href="info.php" class="hyper"><i class="fa fa-sign-in" ></i> 정보수정</a>
<?php }  ?>

</div>

와 같이 하시면 될 듯 합니다.

Copy
if($member['mb_id']) {

   <a href="login.php" class="hyper"><i class="fa fa-sign-in"></i> 로그인</a>

   <a href="register.php" class="hyper"><i class="fa fa-unlock" aria-hidden="true"></i> 회원가입</a>

} else {  

   <a href="logout.php" class="hyper"><i class="fa fa-sign-in"></i> 로그아웃</a>

   <a href="info.php" class="hyper"><i class="fa fa-sign-in" ></i> 정보수정</a>

}

답변에 대한 댓글 5개

답변 감사합니다.
죄송한데 이 소스를 어떻게 적용해야 할지 몰라서 다시 한번 여쭤 봅니다.

main.php 파일 상단에 알려주신 소스를 넣었더니

<div class="top-contact pull-right">
<a href="main.php" class="hyper"><i class="fa fa-home"></i> 홈으로</a>

<?php
if($member['mb_id']) {
<a href="login.php" class="hyper"><i class="fa fa-sign-in"></i> 로그인</a>
<a href="register.php" class="hyper"><i class="fa fa-unlock" aria-hidden="true"></i> 회원가입</a>
} else {
<a href="logout.php" class="hyper"><i class="fa fa-sign-in"></i> 로그아웃</a>
<a href="info.php" class="hyper"><i class="fa fa-sign-in" ></i> 정보수정</a>
}
?>
</div>

작동이 잘 되지 않아서 그런데..혹시 알려주신 소스 넣으면 상단에 무슨 코드를 더 넣어 줘야 하나요?

지금은 최근글 때문에 아래 소스만 넣어 주었습니다.

<?php
include_once('./_common.php');
include_once(G5_LIB_PATH.'/latest.lib.php')
?>
밑에 port 님이 수정해주셨네요
if($member['mb_id']) { ==> <?php if($member['mb_id']) { ?>
} else { ==> <?php } else { ?>
} ==> <?php } ?>
답변 주소서 감사합니다.

혹시 로그아웃하고 페이지 이동을 원하는 페이지로 이동할려면 어찌 해야 할까요?
지금은 board로 이동하던데
main.php로 이동 시키고 싶은데..
저는 logout.php 를 찾아서 해당부분을 수정했습니다.

설정이나 이런곳에 있는지는 모르겠네요 ^^
이 부분은 특정 게시판에서만 사용할 경우와 전체 게시판에서 동일하게 사용할 경우에 달라질수 있겠네요.
특정 게시판 일 경우(예를 들어 게시판명이 freeboard)
logout.php 파일에서
} else if ($bo_table) {
$link = G5_BBS_URL.'/board.php?bo_table='.$bo_table;
} else {
$link = G5_URL;
}
부분을
} else if ($bo_table) {
if($bo_table == "freeboard") {
$link = G5_URL.'/main.php';
} else {
$link = G5_BBS_URL.'/board.php?bo_table='.$bo_table;
}
} else {
$link = G5_URL;
}
로 하면 될구요.

모든 게시판일 경우는
} else if ($bo_table) {
$link = G5_URL.'/main.php';
} else {
$link = G5_URL;
}
로 하면 될 듯 하네요.

답변을 작성하려면 로그인이 필요합니다.