디비 연결 테스트 ¶
<?php
$link = mysql_connect('mysql5.hosting.paran.com', 'linflus', '****');
if (!$link) {
die('Could not connect: ' . mysql_error());
}else{
echo("Connect Succesful.<br/>");
}
$db = mysql_select_db("linflus_db");
/*
$sql = "CREATE TABLE guest
(no integer not null,
name char(10),
contents text(2000),
password char(4),
status integer,
date date)";
$result = mysql_query($sql);
if(!$result){
die('Can not create table');
}else{
echo($result);
}
*/
$sql = "INSERT INTO guest
values(1, 'ksh', 'hello', '1234', 1)";
$result = mysql_query($sql);
$sql = "SELECT * FROM guest";
$result = mysql_query($sql);
$obj = mysql_fetch_object($result);
echo($obj->name);
?>
기본 화면 (index.php) ¶
<html> <head><title>방명록</title><head> <body> <form method='post' action='output.php'> 이름 <input type='text' name='input_name' size='10'> 비밀번호 <input type="password" name='input_pw'size='4' maxlength='4'> <br> <textarea name='context' rows='4' cols='50'></textarea> <br> <input type='submit' value=' 전송 '> </form> </body> </html>
글자 수 제한의 처리 (process.php) ¶
<?
//이름 입력의 처리
if (strlen($_POST['input_name']) > 10 )
{
$posted_name = substr($_POST['input_name'],0,10);
}
else
{
$posted_name = $_POST['input_name'];
}
//비번 입력의 처리
if (strlen($_POST['input_pw']) > 4 )
{
$posted_pw = substr($_POST['input_pw'],0,4);
}
else
{
$posted_pw = $_POST['input_pw'];
}
//내용 입력의 처리
if (strlen($_POST['context']) > 2000 )
{
$posted_context = substr($_POST['context'],0,2000);
}
else
{
$posted_context = $_POST['context'];
}
?>
입력 받은 내용 출력 (output.php) ¶
<html><head><title></title></head><body>
<?
include_once("process.php");
echo("입력받은 이름 : ".$_POST['input_name']."<br>");
echo("입력받은 비번 : ".$_POST['input_pw']."<br>");
echo("입력받은 내용 : ".$_POST['context']."<br>");
echo("<br>");
echo("출력된 이름(10byte) : ".$posted_name."<br>");
echo("출력된 비번(04byte) : ".$posted_pw."<br>");
echo("출력된 내용(2000byte) : ".$posted_context."<br>");
?>
</body>
</html>
오늘의 상태 ¶
나머지 부분은 생략
기본화면에 첨부하면 되므로..ㅋ
기본화면에 첨부하면 되므로..ㅋ
<html> <head><title>방명록</title><head> <body> . . <input type = "radio" name = "state" value = "1" size = "40" checked><img src="1.jpg"> <input type = "radio" name = "state" value = "2" size = "40"><img src="2.jpg"> <input type = "radio" name = "state" value = "3" size = "40"><img src="3.jpg"> <input type = "radio" name = "state" value = "4" size = "40"><img src="4.jpg"> . </form> </body> </html>










