리눅스

 

view.php

 

<?php
	
	include_once("dbcon.php");
	
	$query="select * from guestbook where idx=".$_GET["idx"];
	$rs=mysql_query($query);
	
	if($row=mysql_fetch_array($rs)){
		$name=$row["name"];
		$email=$row["email"];	
		$content=$row["content"];
		$idx=$row["idx"];		
	}
?>

<!DOCTYPE HTML>

<html>

<head>

<script>
	function update(){
		
		document.form1.action="guestbookalter.php";
		document.form1.submit();
		
	}
	
	function del(){
		
		if(confirm("정말 삭제 하시겠습니까?")){
			document.form1.action="del.php";
		    document.form1.submit();	
		}
		
	}
	
</script>

	
</head>	

<body>



	<h2>방명록 작성</h2>
	
<form action="alter.php" method="post" name="form1">
  <table border="1" width="500px">
  	<tr>
  		<td>이름</td>
  		<td><input type="text" name="name" value="<?php echo $name; ?>"></td>
  	</tr>
  	<tr>
  		<td>이메일</td>
  		<td><input type="text" name="email" value="<?php echo $email;?>"></td>
  	</tr>

  	<tr>
  		<td>내용</td>
  		<td><textarea name="content" rows="8" cols="40"><?php echo $content ; ?></textarea></td>
  	</tr>
  	
  	<tr>
  		
  		<td colspan="2">
  			<input type="hidden" value="<?php  echo $idx; ?>" name="idx">
  			<input type="submit" value="수정" onclick="update();">
		<input type="submit" value="삭제" onclick="del();">
		</td>
  	</tr>
  	
  </table>
</form>	
	
	
</body>	
	
</html>







 

guestbookalter.php

<?php
    
    
    include_once("dbcon.php");
	
		$name=$_POST["name"];
		$email=$_POST["email"];	
		$content=$_POST["content"];
		$idx=$_POST["idx"];
    
	$query ="
		update guestbook set name='$name' , email='$email' ,
				content='$content' where idx=$idx
	
	";
	
	mysql_query($query);
	
?>



<script>
	
	location.href="list.php";
	
</script>

 

del.php

<?php
 
 include_once("dbcon.php");
 
 $query =" delete from guestbook where idx=".$_POST['idx'];
 
 mysql_query($query);
?>


<script>
	
	location.href="list.php";
	
</script>

 

 

 

 

 

 

 

about author

PHRASE

Level 60  머나먼나라

사랑은 정신과 정신, 육체와 육체가 창조의 기쁨 속에서 황급히 끌어당기는 인력이다.

댓글 ( 0)

댓글 남기기

작성
  •    
  •    
  •