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!!!