사용자가 처음 접속했을 때 보여지는 화면을 만든다.
<?php // 로그인 되어 있으면 목록으로 이동 session_start(); if (isset($_SESSION['member_id'])){ header("Location: /list.php"); exit(); } // 서비스 소개 ?> <!DOCTYPE html> <html> <head> <title>php-memo 목록</title> </head> <body> <?php require_once("inc/header.php"); ?> <h1>php-memo 첫 페이지</h1> </body> </html>
위 코드를 index.php 파일로 저장한다.
메인 페이지는 이미 로그인되어 있다면 메모 목록 페이지로 이동한다.
// 로그인 되어 있으면 목록으로 이동 session_start(); if (isset($_SESSION['member_id'])){ header("Location: /list.php"); exit(); }
로그인되어있지 않을 경우 서비스 소개 페이지를 보여준다.
Copy<!DOCTYPE html> <html> <head> <title>php-memo 목록</title> </head> <body> <?php require_once("inc/header.php"); ?> <h1>php-memo 첫 페이지</h1> </body> </html>