티스토리 뷰

Web

로그인 Test

Tribal 2016. 2. 15. 14:30
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
######################################### Login_OK.php ###########################################
<html>
<head>
    <title>Login Check</title>
    <meta http-equiv="Content-Type" content="text/html; charset=euc-kr" />
</head>
<body>
<?php
 
    include "./dbconn.php";
 
    $id = $_GET['id'];
    $pw = $_GET['pw'];
 
    $query = "SELECT * FROM accounts WHERE id = '{$id}' AND pw = '{$pw}'";
 
    $result = mysqli_query($dbconn$query) or die("Hello");
 
    $rows = mysqli_fetch_assoc($result);
 
    echo "Welcome!!<br><br>";
    if($rows['id']) {
        echo "Hello, {$id}!";
    }
    else {
        echo "Login Fail";
    }
?>
</body>
</html>
cs


1
2
3
4
5
6
7
8
9
10
11
12
13
######################################### dbconn.php #################################################
<?php
    $host   = "localhost";    //127.0.0.1
    $user   = "root";
    $pass   = "@@@@@@@@";
    $db        = "security";
 
    echo "22";
    $dbconn = mysqli_connect($host$user$pass) or die("DB Connect Err");
    mysqli_select_db($dbconn$db) or die("DB select Err");
    mysqli_query("SET NAMES euc-kr");
?>
 
cs


1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
<!-------------------------------- index.html --------------------------------->
<html>
    <head>
    <title>login Page</title>
    <meta http-equiv="Content-Type" content="text/html; charset=euc-kr" />
    </head>
    <body>
    <form action="Login_OK.php" method="GET">
        <table>
        <tr>
            <td>ID</td>
            <td><input type="text" name="id"></td>
        </tr>
        <tr>
            <td>Password</td>
            <td><input type="password" name="pw"></td>
        </tr>
        <tr>
            <td colspan="2"><input type="submit" value="Login"></td>
        </tr>
        </table>
    </form>
    </body>
</html>
cs



Fail!!


Success!!!


'Web' 카테고리의 다른 글

MongoDB 설치 및 사용 방법  (0) 2017.03.26
php 에러 출력  (0) 2016.02.15
Mysql 데이터베이스 추가, 삭제  (0) 2016.02.15
SQL injection filter  (0) 2016.02.15
Web Sever 구축 정리  (0) 2016.02.11
댓글
최근에 올라온 글
최근에 달린 댓글
Total
Today
Yesterday
«   2025/02   »
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