반응형
php 좋아요 기능& 알림기능 구현 1 (로그인 부분)
#화면
#경로
#login.php
<?php
include("database_connection.php");
$msg = '';
if(isset($_POST["login"]))
{
if(empty($_POST["user_email"]) || empty($_POST["user_password"]))
{
$msg = '<label>빈칸을 채워주세요</label>';
}
else
{
$query = "select * from user_details where user_email = :user_email";
$statment = $connect ->prepare($query);
$statment -> execute(
array('user_email' => $_POST["user_email"])
);
$count = $statment -> rowCount();
if($count > 0 )
{
$result =$statment ->fetchAll();
foreach($result as $row)
{
if(password_verify($_POST["user_password"],$row["user_password"]))
{
$_SESSION['user_id'] = $row['user_id'];
$_SESSION['user_name'] = $row['user_name'];
header("location:index.php");
}else
{
$msg = '<label>잘못된 비밀번호 입니다</label>';
}
}
}
else
{
$msg = '<label>잘못된 이메일 주소 입니다</label>';
}
}
}
?>
<!DOCTYPE html>
<html>
<head>
<title>php 좋아요 기능과 알림기능</title>
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css" />
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/js/bootstrap.min.js"></script>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.2.0/jquery.min.js"></script>
</head>
<body>
<br />
<div class="container">
<h2 align="center">php 좋아요 기능과 알림기능</h2>
<br />
<div class="panel panel-default">
<div class="panel-heading">로그인</div>
<div class="panel-body">
<!-- 로그인 폼 -->
<form method = "post">
<span class="text-danger"><?php echo $msg; ?></span>
<div class="form-group">
<label>이메일</label>
<input type="text" name="user_email" id="user_email" class="form-control" />
</div>
<div class="form-group">
<label>비밀번호</label>
<input type="password" name="user_password" id="user_password" class="form-control" />
</div>
<div class="form-group">
<input type="submit" name="login" id="login" class="btn btn-info" value="로그인"/>
</div>
</form>
</div>
</div>
</div>
</div>
</body>
</html>
#database_connection
<?php
$connect = new PDO("mysql:host=localhost; dbname=db이름","root","비번");
session_start();
?>
#index.php
<?php
include("database_connection.php");
if(!isset($_SESSION["user_id"]))
{
header("location:login.php");
}
?>
<!DOCTYPE html>
<html>
<head>
<title>php 좋아요 기능과 알림기능</title>
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css" />
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/js/bootstrap.min.js"></script>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.2.0/jquery.min.js"></script>
</head>
<body>
<br />
<div class="container">
<h2 align="center">php 좋아요 기능과 알림기능</h2>
<br />
<div align="right">
<a href="logout.php">로그아웃</a>
</div>
<br />
<br />
<br />
<br />
<br />
</div>
</body>
</html>
#logout.php
<?php
session_start();
session_destroy();
header("location:login.php");
?>
반응형
'PHP 박살내기 > php ajax json' 카테고리의 다른 글
php 좋아요 기능& 알림기능 구현 3 (좋아요 부분) (0) | 2017.09.20 |
---|---|
php 좋아요 기능& 알림기능 구현 2 (좋아요 총개수 불러오기& 글 삽입 기능) (0) | 2017.09.19 |
PHP 객체지향 방식으로 Mysql Ajax 조회 추가 수정 삭제 (0) | 2017.09.18 |
ajax jquery php 사용해서 Add Edit Delete 하기 (LIVE TABLE 구현) - 동적테이블 (2) | 2017.09.18 |
php mysql ajax bootstrapModal을 이용해서 동적 웹페이지 만들기3 (수정) (1) | 2017.09.15 |
댓글