Monthly Archives: 10월 2014

WebDB(II) 실습예제 소스 #10

<?php session_start(); ?> <!DOCTYPE html> <html> <head> <meta charset=”UTF-8″> <title>examSQL-19.php</title> </head> <body> <?php require ‘./dbConn.php’; $link = mysqli_connect($dbHost, $dbUser, $dbPass); // MySQL 서버 연결 if (!$link) { // DB연결에 실패한 경우 ($!link, $link!=true, $link==false 모두 동일) echo “DB 연결에 실패했습니다.”; exit(); // 프로그램 종료 } $db = mysqli_select_db($link, $dbName); // Database 선택 if (!$db) {… Read More »

WebDB(II) 실습예제 소스 #9

<?php session_start(); ?> <!DOCTYPE html> <html> <head> <meta charset=”UTF-8″> <title>SetSession</title> </head> <body> 세션ID : <?= session_id() ?><br/> <?php $_SESSION[“session1”] = “세션1”; $_SESSION[“session2”] = “세션2”; $_SESSION[“session3”] = “세션3″; ?> <a href=”./showSession.php”>세션확인</a> </body> </html> <?php session_start(); ?> <!DOCTYPE html> <html> <head> <meta charset=”UTF-8″> <title>ShowSession</title> </head> <body> 세션ID : <?= session_id() ?><br/> session1 : <?= $_SESSION[“session1”] ?><br/> session2… Read More »

WebDB(II) 실습예제 소스 #8

참조 : http://blog.ysoh.pe.kr/entry/쿠키 <!DOCTYPE html> <html> <head> <meta charset=”UTF-8″> <title>SetCookies</title> </head> <body> 쿠키설정시각 : <?= date(“Y-m-d H:i:s”) ?><br/> <?php setcookie(“cookie1”, “쿠키#1”, 0, “/”); // 브라우저 종료 전까지 유지 setcookie(“cookie2”, “쿠키#2”, time() + 60, “/”); // 설정 후 1분 동안 유지 setcookie(“cookie3”, “쿠키#3”, mktime(16, 0, 0, 10, 17, 2014), “/”); // 2014년10월17일 16시00분00초 까지 유지 ?>… Read More »

WebDB(II) 실습예제 소스 #7

<!DOCTYPE html> <html> <head> <meta charset=”UTF-8″> <title>examSQL-18.php</title> <style> .field-name {float:left; width:100px;text-align:right;} .field-input input {margin-left: 10px;} </style> </head> <body> <h1>로그인</h1> <form method=”post” action=”examSQL-19.php”> <div class=”field-name”>아이디 : </div> <div class=”field-input”><input type=”text” name=”a” /></div> <div class=”field-name”>비밀번호 : </div> <div class=”field-input”><input type=”password” name=”b” /></div> <div class=”field-name”>&nbsp;</div> <div class=”field-input”><input type=”submit” value=”로그인” /></div> </form> </body> </html> <!DOCTYPE html> <html> <head> <meta… Read More »

WebDB(II) 실습예제 소스 #6

<?php require ‘./dbConn.php’; $link = mysqli_connect($dbHost, $dbUser, $dbPass); // MySQL 서버 연결 if (!$link) { // DB연결에 실패한 경우 ($!link, $link!=true, $link==false 모두 동일) echo “DB 연결에 실패했습니다.<br/>”; exit(); // 프로그램 종료 } $db = mysqli_select_db($link, $dbName); // Database 선택 if (!$db) { // DB선택에 실패한 경우 ($!$db, $db!=true, $db==false 모두 동일) echo “{$dbName} 이름의… Read More »