13. Mysql을 이용한 메모장 (4) 수정 -php-

 

 

-memo_modify.php

<?

include "memo.php";

if(!$_GET['m_idx']){

?>

<script>

alert("메모 번호가 없음");

history.back();

</script>

<?

exit;

} else {

$m_idx=$_GET['m_idx'];

}

$db_host = "mysql.com";

$db_user = "mydb";

$db_pass = "password";

$db_name = "db이름";

//database와 연결.

$connect=mysql_connect($db_host, $db_user, $db_pass) or die(mysql_error());

mysql_query("set names utf8");//한글 입력을 위한 설정.

mysql_select_db($db_name) or die(mysql_error());

$query="SELECT * FROM sample_memo WHERE m_idx='$m_idx'";

$result=mysql_query($query);

$data=mysql_fetch_array($result);//한 행만 불러오면 되므로 그냥 한 번만 대입해서 사용.

if(!$data['m_idx']){

?>

<script>

alert("메모가 없음");

history.back();

</script>

<?

exit; //if문 탈출

}

?>

<!--수정용 form 작성 -->

<br>

<form name="iform" method="post" action="memo_modify_update.php">

<input type="hidden" name="m_idx" value="<?=$data['m_idx']?>">

<table style="width:500px; height:50px; border:5px #cccccc solid;">

<tr>

<td align="center" valign="middle">

메모 수정하기

</td>

</tr>

</table>

<table style="width:500px; height:50px; border:5px #cccccc solid;">

<tr>

<td align="center" valign="middle">이름</td>

<td align="center" valign="middle">

<input type="text" name="m_name" style="width:380px;" value="<?=$data['m_name']?>">

</td>

</tr>

<tr>

<td align="center" valign="middle">이메일</td>

<td align="center" valign="middle">

<input type="text" name="m_email" style="width:380px;" value="<?=$data['m_email']?>">

</td>

</tr>

<tr>

<td align="center" valign="middle">비밀번호</td>

<td align="center" valign="middle">

<input type="text" name="m_pass" style="width:380px;" value="<?=$data['m_pass']?>">

</td>

</tr>

<tr>

<td align="center" valign="middle">내용</td>

<td align="center" valign="middle">

<input type="text" name="m_memo" style="width:380px;" value="<?=$data['m_memo']?>">

</td>

</tr>

<tr>

<td colspan=2 align="center" valign="middle">

<input type="submit" value="저장">

</td>

</tr>

</table>

</form>

<?

mysql_close($connect);

?>

Posted by star story :

Snippet :: Code View :: "+location.href+'
'+b+"

");top.consoleRef.document.close()}$(".snippet-container").each(function(b){$(this).find("a.snippet-text").click(function(){var d=$(this).parents(".snippet-wrap").find(".snippet-formatted");var c=$(this).parents(".snippet-wrap").find(".snippet-textonly");d.toggle();c.toggle();if(c.is(":visible")){$(this).html("html")}else{$(this).html("text")}return false});$(this).find("a.snippet-window").click(function(){var c=$(this).parents(".snippet-wrap").find(".snippet-textonly").html();a(c);$(this).blur();return false})});$(".snippet-toggle").each(function(b){$(this).click(function(){$(this).parents(".snippet-container").find(".snippet-wrap").toggle()})})});