Difference between r1.17 and the current
@@ -38,26 +38,64 @@
echo($obj->name);
?>
}}}
<html>
<br>
<br>
</form>
</html>
}}}
if (strlen($_POST['input_name']) > 10 )
{
?>
}}}
== 기본 화면 (index.php) ==
== 입출력 최종 완성 (9월 8일) ==
= 메인화면 ( index.php ) =
{{{<html>
<head><title>방명록</title><head>
<head>
<META http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>방명록</title>
<?php
include "dbconnect.php";
?>
<head>
<body><form method='post' action='output.php'>
<form method='post' action='process.php'>
이름 <input type='text' name='input_name' size='10'>
이름 <input type='text' name='input_name' maxlength='10' size='10'>
비밀번호 <input type="password" name='input_pw'size='4' maxlength='4'><br>
<input type = "radio" name = "status" value = "1" size = "40" checked><img src="http://cfile234.uf.daum.net/image/152622034C88B1DC682870">
<input type = "radio" name = "status" value = "2" size = "40"><img src="http://cfile223.uf.daum.net/image/162622034C88B1DC696BEC">
<input type = "radio" name = "status" value = "3" size = "40"><img src="http://cfile206.uf.daum.net/image/142622034C88B1DC6AA52F">
<input type = "radio" name = "status" value = "4" size = "40"><img src="http://cfile232.uf.daum.net/image/152622034C88B1DC6BFF47">
<input type = "radio" name = "status" value = "5" size = "40"><img src="http://cfile234.uf.daum.net/image/162622034C88B1DC6C0395">
<br>
<textarea name='context' rows='4' cols='50'></textarea><br>
<input type='submit' value=' 전송 '>
<input type='submit' value='전송'>
<?
include "print.php";
?>
</body></html>
== 글자 수 제한의 처리 (process.php) ==
== 데이터베이스에 연결 ( dbconnect.php ) ==
{{{<?
<?php
$dbconn = mysql_connect("intra.zeropage.org", "csephp", "2010php");
$tableconn = mysql_select_db("csephp_db", $dbconn);
?>
}}}
== 쿼리를 만들때 시간을 저장하기 위해.. ( get_time.php ) ==
{{{
<?php
$unix_ts=mktime();
$date=date('Y-m-d', $unix_ts);
?>
}}}
== 모든 처리는 여기서... ( process.php ) ==
{{{
<?php
include "dbconnect.php";
/*********************
* 쿼리를
* 만듭니다.
*********************/
//이름 입력의 처리if (strlen($_POST['input_name']) > 10 )
{
@@ -87,36 +125,34 @@
{
$posted_context = $_POST['context'];
}
}}}
{{{
<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>
}}}
=== 페이지(page.php) ===
include_once("data.php");
//전체 페이지( $total_page ) 계산
if(!$page) $page = 1;
$posted_context = $_POST['context'];
}
$posted_status = $_POST['status'];
include "get_time.php";
$query = "insert into guest (name, pw, status, contents, date) values ('$posted_name', '$posted_pw', '$posted_status', '$posted_context', '$date')";
/*********************
* 쿼리를 전송
* 합니다.
*********************/
if(($posted_name!="")&&($posted_pw!="")&&($posted_pw!=""))
{
$result = mysql_query($query, $dbconn);
}
header("location:index.php");
?>== 입력 받은 내용 출력 (output.php) ==
== 입력을 받고, 출력(페이지 추가) ( print.php ) ==
{{{<?
<?php
$query = "select * from guest ORDER BY no DESC";
$result = mysql_query($query, $dbconn);
$record_number = mysql_num_rows($result);
$scale = 10;//한 페이지당 글 수//전체 페이지( $total_page ) 계산
if( $total % $scale == 0)
$total_page = floor($total / $scale );
if( $record_number % $scale == 0)
$total_page = floor($record_number / $scale );
else $total_page = floor($total / $scale) + 1;
$total_page = floor($record_number / $scale) + 1;
if(!$page) $page = 1;
@@ -124,11 +160,13 @@
$start = ($page -1) * $scale;
echo $arr[$i]->input_name;
echo $arr[$i]->context;
}
for( $i=1; $i<=$total_page; $i++){
for( $i = $start; $i < $start + $scale && $i < $total; $i++){
echo $arr[$i]->input_pw;
echo "<br>";
for( $i = $start; $i < $start + $scale && $i < $record_number; $i++){
include "get_record.php";
echo("<br>기본정보 : $name $no $pw $status $date <br>");
echo("내 용 : $contents <br>");
include "print_status.php";
for( $i=1; $i<=$total_page; $i++){
@@ -136,242 +174,44 @@
echo" <b>[$i]</b>";
}
else{
}
?>
}}}
요건 그냥 데이터(data.php)
{{{
<?
class guestBook {
var $input_name;
var $input_pw;
var $context;
}
$total = 12;//전체 글 수
$arr[12] = new guestBook;
$arr[0]->input_name = '강소현';
$arr[0]->input_pw = '1111';
$arr[0]->context = '반가워요 ?';
$arr[1]->input_name = '강승현';
$arr[1]->input_pw = '1122';
$arr[1]->context = '?????';
$arr[2]->input_name = '이정은';
$arr[2]->input_pw = '4444';
$arr[2]->context = '이런!! ㅠㅠㅠㅠ';
$arr[3]->input_name = '초운영';
$arr[3]->input_pw = '5555';
$arr[3]->context = '수강신청 실패 ㅠㅠ';
$arr[4]->input_name = '김상호';
$arr[4]->input_pw = '1242';
$arr[4]->context = '오늘도 지각이에요 ㅠㅠㅋ';
$arr[5]->input_name = '박정근';
$arr[5]->input_pw = '4576';
$arr[5]->context = '안녕하세요??';
$arr[6]->input_name = '컴공인';
$arr[6]->input_pw = '9994';
$arr[6]->context = '여기는 6피';
$arr[7]->input_name = '아아아';
$arr[7]->input_pw = '5221';
$arr[7]->context = '이름이 안 떠올라';
$arr[8]->input_name = '살려줘';
$arr[8]->input_pw = '4524';
$arr[8]->context = '이런!! ㅠㅠ 한계가 왔어!';
$arr[9]->input_name = '언제까지';
$arr[9]->input_pw = '1300';
$arr[9]->context = '이어지니?';
$arr[10]->input_name = '에구구';
$arr[10]->input_pw = '1142';
$arr[10]->context = '길디 길다';
$arr[11]->input_name = '공학관';
$arr[11]->input_pw = '4523';
$arr[11]->context = '입니다 ㅇㅁㅇ';
?>
}}}
== 오늘의 상태 ==
나머지 부분은 생략
기본화면에 첨부하면 되므로..ㅋ
{{{
<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>
}}}
== 색 바꾸기 ==
{{{
<?
echo("<h1>배경색을 바꾸자</h1><br>");
echo("
<form method='post' action='$PHP_SELF'>
R <input type='text' maxlength='3' name='setr' size='3'><br>
G <input type='text' maxlength='3' name='setg' size='3'><br>
B <input type='text' maxlength='3' name='setb' size='3'><br>
혹은 그냥 색 이름 입력(영어로) <input type='text' name='clrname'><br>
<input type='submit' value='전송'>
");
if($_POST['clrname'] != NULL)
{
echo('<body bgcolor='.$_POST['clrname'].'>');
}
else
{
// 배경 색의 처리
$hexr=dechex($_POST['setr']);
$hexg=dechex($_POST['setg']);
$hexb=dechex($_POST['setb']);
echo('<body bgcolor='.$hexr.$hexg.$hexb.'>');
}
// 글자가 보이기 위해 글자 색의 처리
$txtr=dechex(255-$_POST['setr']);
$txtg=dechex(255-$_POST['setg']);
$txtb=dechex(255-$_POST['setb']);
?>
}}}
== 디비가 연결된 새로운 방명록 아래부터 시작~ ==
= 메인화면 ( index.php ) =
{{{
<html>
<head>
<META charset='utf-8'>
<title>방명록</title>
<?
include "dbconnect.php";
?>
<head>
<body>
<form method='post' action='index.php'>
이름 <input type='text' name='input_name' maxlength='10' 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>
<?
include "make_query.php";
include "process.php";
include "print.php";
include "get_time.php";
?>
</body>
</html>
}}}
<?
if($dbconn) {
echo("db 연결 성공 <br>");
}
else
{
echo("db 연결 실패 <br>");
}
if($tableconn) {
echo("table 연결 성공 <br>");
}
else
{
echo("table 연결 실패 <br>");
}
echo("<br>"." ------------------------------------------"."<br>");
}}}
//이름 입력의 처리
$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'];
//내용 입력의 처리
$posted_context = substr($_POST['context'],0,2000);
else
$posted_context = $_POST['context'];
include "get_time.php";
$query = "insert into guest (name, pw, contents, date) values ('$posted_name', '$posted_pw', '$posted_context', '$date')";
?>
}}}
{{{
<?
$unix_ts=mktime();
$date=date('Y-m-d', $unix_ts);
?>
}}}
== 입력을 받고, 이제 전체 테이블 출력! ( print.php ) ==
<?
$query = "select * from guest";
$result = mysql_query($query, $dbconn);
$record_number = mysql_num_rows($result);
for($i=0 ; $i < $record_number ; $i ++)
{
include "get_record.php";
echo("기본정보 : $name $no $pw $status $date <br>");
echo("내 용 : $contents <br><br>");
?>
}}}
[2010PHP]
}
else{
echo"<a href='page.php?page=$i'>[$i]</a>";
echo"<a href='index.php?page=$i'>[$i]</a>";
}}
?>
}}}
== 데이터베이스에 연결 ( dbconnect.php ) ==
== 출력을 위해 필요함 ( get_record.php ) ==
{{{<?
$dbconn = mysql_connect("intra.zeropage.org", "csephp", "2010php");
$tableconn = mysql_select_db("csephp_db", $dbconn);
$name=mysql_result($result,$i,0);
$no=mysql_result($result,$i,1);
$pw=mysql_result($result,$i,2);
$contents=mysql_result($result,$i,3);
$status=mysql_result($result,$i,4);
$date=mysql_result($result,$i,5);
?>}}}
== 입력받은 내용을 쿼리로 만들어서 쏜다! ( make_query.php ) ==
== 오늘의 상태 (print_status.php) ==
{{{<?
if (strlen($_POST['input_name']) > 10 )
{
//비번 입력의 처리
<?php
if ($status == 1) {
echo("<img src = 'http://cfile234.uf.daum.net/image/152622034C88B1DC682870'><br>");
}{
if ($status == 2) {
echo("<img src = 'http://cfile223.uf.daum.net/image/162622034C88B1DC696BEC'><br>");
}if (strlen($_POST['context']) > 2000 )
{
if ($status == 3) {
echo("<img src = 'http://cfile206.uf.daum.net/image/142622034C88B1DC6AA52F'><br>");
}{
if ($status == 4) {
echo("<img src = 'http://cfile232.uf.daum.net/image/152622034C88B1DC6BFF47'><br>");
}== 쿼리를 만들때 시간을 저장하기 위해.. ( get_time.php ) ==
echo('<br>');
if ($status == 5) {
echo("<img src = 'http://cfile234.uf.daum.net/image/162622034C88B1DC6C0395'><br>");
}?>
}}}
== 계층도랄까.. ==
[http://cfile231.uf.daum.net/image/166494114C8748111943D9 클릭하셈]
----[2010PHP]
디비 연결 테스트 ¶
<?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); ?>
입출력 최종 완성 (9월 8일) ¶
메인화면 ( index.php ) ¶
<html> <head> <META http-equiv="Content-Type" content="text/html; charset=utf-8"> <title>방명록</title> <?php include "dbconnect.php"; ?> <head> <body> <form method='post' action='process.php'> 이름 <input type='text' name='input_name' maxlength='10' size='10'> 비밀번호 <input type="password" name='input_pw'size='4' maxlength='4'> <br> <input type = "radio" name = "status" value = "1" size = "40" checked><img src="http://cfile234.uf.daum.net/image/152622034C88B1DC682870"> <input type = "radio" name = "status" value = "2" size = "40"><img src="http://cfile223.uf.daum.net/image/162622034C88B1DC696BEC"> <input type = "radio" name = "status" value = "3" size = "40"><img src="http://cfile206.uf.daum.net/image/142622034C88B1DC6AA52F"> <input type = "radio" name = "status" value = "4" size = "40"><img src="http://cfile232.uf.daum.net/image/152622034C88B1DC6BFF47"> <input type = "radio" name = "status" value = "5" size = "40"><img src="http://cfile234.uf.daum.net/image/162622034C88B1DC6C0395"> <br> <textarea name='context' rows='4' cols='50'></textarea> <br> <input type='submit' value='전송'> </form> <? include "print.php"; ?> </body> </html>
데이터베이스에 연결 ( dbconnect.php ) ¶
<?php $dbconn = mysql_connect("intra.zeropage.org", "csephp", "2010php"); $tableconn = mysql_select_db("csephp_db", $dbconn); ?>
쿼리를 만들때 시간을 저장하기 위해.. ( get_time.php ) ¶
<?php $unix_ts=mktime(); $date=date('Y-m-d', $unix_ts); ?>
모든 처리는 여기서... ( process.php ) ¶
<?php include "dbconnect.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']; } $posted_status = $_POST['status']; include "get_time.php"; $query = "insert into guest (name, pw, status, contents, date) values ('$posted_name', '$posted_pw', '$posted_status', '$posted_context', '$date')"; /********************* * 쿼리를 전송 * 합니다. *********************/ if(($posted_name!="")&&($posted_pw!="")&&($posted_pw!="")) { $result = mysql_query($query, $dbconn); } header("location:index.php"); ?>
입력을 받고, 출력(페이지 추가) ( print.php ) ¶
<?php $query = "select * from guest ORDER BY no DESC"; $result = mysql_query($query, $dbconn); $record_number = mysql_num_rows($result); $scale = 10;//한 페이지당 글 수 //전체 페이지( $total_page ) 계산 if( $record_number % $scale == 0) $total_page = floor($record_number / $scale ); else $total_page = floor($record_number / $scale) + 1; if(!$page) $page = 1; //페이지에 따라 $start 계산 $start = ($page -1) * $scale; for( $i = $start; $i < $start + $scale && $i < $record_number; $i++){ include "get_record.php"; echo("<br>기본정보 : $name $no $pw $status $date <br>"); echo("내 용 : $contents <br>"); include "print_status.php"; } for( $i=1; $i<=$total_page; $i++){ if($page == $i){ echo" <b>[$i]</b>"; } else{ echo"<a href='index.php?page=$i'>[$i]</a>"; } } ?>
출력을 위해 필요함 ( get_record.php ) ¶
<? $name=mysql_result($result,$i,0); $no=mysql_result($result,$i,1); $pw=mysql_result($result,$i,2); $contents=mysql_result($result,$i,3); $status=mysql_result($result,$i,4); $date=mysql_result($result,$i,5); ?>
오늘의 상태 (print_status.php) ¶
<?php if ($status == 1) { echo("<img src = 'http://cfile234.uf.daum.net/image/152622034C88B1DC682870'><br>"); } if ($status == 2) { echo("<img src = 'http://cfile223.uf.daum.net/image/162622034C88B1DC696BEC'><br>"); } if ($status == 3) { echo("<img src = 'http://cfile206.uf.daum.net/image/142622034C88B1DC6AA52F'><br>"); } if ($status == 4) { echo("<img src = 'http://cfile232.uf.daum.net/image/152622034C88B1DC6BFF47'><br>"); } if ($status == 5) { echo("<img src = 'http://cfile234.uf.daum.net/image/162622034C88B1DC6C0395'><br>"); } ?>