주소록 프로젝트
주소록 만들기
주 소 록
Input페이지 Edit페이지 Del페이지 List페이지
Inputpro페이지 Editpro 페이지
Address_Input.html
<html>
<head>
<title> 주소 입력페이지 </title>
<body>
<style>
td,li,input{font-size:9pt}
</style>
주소 입력
<li, input style="line-height:80%">
<form action=address_inputpro.html>
<li>이 름 : <input type=text name=name size=10 maxlength=10>
<li>전화번호 : <input type=text name=phone size=20 maxlength=20>
<li>성 별 : <input type=radio name=sex value="남자">남자 <input type=radio name=sex value="여자">여자
<li>주 소 : <input type=text name=address size=40 maxlength=40>
<li>메 일 : <input type=text name=mail size=20 maxlength=30>
<li>생 일 : <input type=text name=birth size=10 maxlength=10>
<li>메 모 : <input type=text name=memo size=40 maxlength=200><br>
<input type=submit value="입력"> <input type=reset>
</form>
</body>
</html>
Address_Inputpro.html
<html>
<head>
<title> </title>
<body>
<?
$connect = mysql_connect("localhost","MySQLID","MySQLPW") or die("데이터베이스에 연결할 수 없습니다.");
mysql_select_db("learntorial");
$query = "insert into address(name, phone, sex, address, mail, birth, memo) values('$name','$phone','$sex','$address','$mail','$birth','$memo')";
mysql_query($query, $connect);
mysql_close($connect);
?>
<script>
location.href="address_list.html"
</script>
</body>
</html>
Address_list.html
<html>
<head>
<title> 프로젝트 1 주소록 </title>
<body>
<SCRIPT LANGUAGE="JavaScript">
function check(){
if(document.search.search.value=="") {
alert('검색어를 입력하여 주세요.');
document.search.search.focus();
return false;
}
document.search.submit();
}
</SCRIPT>
<style>
td,li,input{font-size:9pt}
</style>
<table border=1 width=80% cellpadding=5 cellspacing=1 bgcolor=#000000>
<tr bgcolor=#ffffff align=center>
<td colspan=9><font size=+2 color=bluesky><프로젝트 1 주소록></font>
<tr bgcolor=#ffffff align=left>
Address_list.html
<td>이름<td>전화번호<td>성별<td>주소<td>메일주소<td>생일<td>메모<td>수정<td>삭제
<?
$connect = mysql_connect("localhost","MySQLID","MySQLPW");
mysql_select_db("learntorial");
$query = "select * from address order by name asc";
$result = mysql_query($query, $connect);
while($data = mysql_fetch_array($result)){
?>
<tr bgcolor=#ffffff align=left>
<td> <?=$data[name]?>
<td> <?=$data[phone]?>
<td> <?=$data[sex]?>
<td> <?=$data[address]?>
<td> <?=$data[mail]?>
<td> <?=$data[birth]?>
<td> <?=$data[memo]?>
<td> <a href="address_edit.html?no=<?=$data[no]?>"> 수정 </a>
<td> <a href="address_del.html?no=<?=$data[no]?>"> 삭제 </a>
Address_list.html
<?
}
mysql_close($connect);
?>
</table>
</form>
<form action=address_search.html name=search method=post>
<input type=text name=search>
<input type=button size=10 name=ok value=검색 onclick="check()">
</form>
<form action=address_input.html>
<input type=submit value=입력페이지로>
</form>
</body>
</html>
Address_edit.html
<html>
<head>
<title> 주소 수정페이지 </title>
<body>
<style>
td,li,input{font-size:9pt}
</style>
주소 수정하기
<?
$connect = mysql_connect("localhost","MySQLID","MySQLPW");
mysql_select_db("learntorial");
$query = "select * from address where no='$no'";
$result = mysql_query($query, $connect);
$data = mysql_fetch_array($result);
?>
<li, input style="line-height:80%">
<form action=address_editpro.html method=post>
<li>이 름 :
<input type=text name=name size=10 maxlength=10 value="<?=$data[name]?>">
<li>전화번호 :
Address_edit.html
<input type=text name=phone size=20 maxlength=20 value="<?=$data[phone]?>">
<li>성 별 :
<?
if($data[sex]=="남자"){
?>
<input type=radio name=sex value="남자" checked>남자 <input type=radio name=sex value="여자">여자
<?
}else{
?>
<input type=radio name=sex value="남자">남자
<input type=radio name=sex value="여자" checked>여자
<? } ?>
<li>주 소 :
<input type=text name=address size=40 maxlength=40 value=“<?=$data[address]?>">
<li>메 일 :
<input type=text name=mail size=20 maxlength=30 value="<?=$data[mail]?>">
<li>생 일 :
<input type=text name=birth size=10 maxlength=10 value="<?=$data[birth]?>">
<li>메 모 :
<input type=text name=memo size=40 maxlength=200 value="<?=$data[memo]?>">
<br>
Address_edit.html
<input type=hidden name=no value="<?=$data[no]?>">
<input type=submit value="입력"> <input type=reset>
</form>
<?
mysql_close($connect);
?>
</body>
</html>
Address_editpro.html
<html> <head> <title> </title>
<body>
<?
$connect = mysql_connect("localhost","MySQLID","MySQLPW") or die("접속불가");
mysql_select_db("learntorial");
$query="update address set name='$name',
phone='$phone', sex='$sex',
address='$address', mail='$mail',
birth='$birth', memo='$memo' where no='$no'";
mysql_query($query, $connect);
mysql_close($connect);
?>
<script>
location.href="address_list.html"
</script> </body> </html>
Address_del.html
<html>
<head>
<title> </title>
<body>
<?
$connect = mysql_connect("localhost","MySQLID","MySQLPW");
mysql_select_db("learntorial");
$query = "delete from address where no='$no'";
$result = mysql_query($query, $connect);
if(!$result) die(mysql_error());
mysql_close($connect);
?>
<script>
location.href='address_list.html'
</script>
</body>
</html>
Address_search.html
<html>
<head>
<title> 검색된 주소록 페이지 </title>
<body>
<style>
td,li,input{font-size:9pt}
</style>
<table border=1 width=80% cellpadding=5 cellspacing=1 bgcolor=#000000>
<tr bgcolor=#ffffff align=center>
<td colspan=9><font size=+2 color=bluesky><종합예제1 홍길동의 주소록></font>
<tr bgcolor=#ffffff align=left>
<td> 이름<td>전화번호<td>성별<td>주소<td>메일주소<td>생일<td>메모<td>수정
<td>삭제
<?
$connect = mysql_connect("localhost","MySQLID","MySQLPW") or die("접속불가");
mysql_select_db("learntorial");
$query = "select * from address where name like '%$search%' order by name asc";
$result = mysql_query($query, $connect);
$data=mysql_fetch_array($result);
Address_search.html
if(!$data[name]){
echo "<tr bgcolor=#ffffff align=center>
<td colspan=9> 검색된 데이터가 없습니다.";
} else{
$query = "select * from address where name like '%$search%' order by name asc";
$result = mysql_query($query, $connect);
while($data = mysql_fetch_array($result)){
?>
<tr bgcolor=#ffffff align=left>
<td> <?=$data[name]?>
<td> <?=$data[phone]?>
<td> <?=$data[sex]?>
<td> <?=$data[address]?>
<td> <?=$data[mail]?>
<td> <?=$data[birth]?>
<td> <?=$data[memo]?>
<td> <a href="address_edit.html?no=<?=$data[no]?>"> 수정 </a>
<td> <a href="address_del.html?no=<?=$data[no]?>"> 삭제 </a>
Address_search.html
<?
} }
mysql_close($connect);
?>
</table>
<form action=address_list.html>
<input type=submit value=전체목록으로>
</form>
</body>
</html>