안효원 안효원 2022-02-09
updateFront modified
@cc1e2f23b9934b86fbb4509a1394fa3fe4848211
20220126/Address.php
--- 20220126/Address.php
+++ 20220126/Address.php
@@ -12,6 +12,17 @@
         $this->db = $db->getDB();
     }
 
+    public function getListWhere($no) {
+        try {
+            $stmt = $this->db->prepare("select * from address where no = ?");
+            $stmt->execute(array($no));
+            $result = $stmt->fetchAll();
+            return $result;
+        }catch (PDOException $e) {
+            return $e;
+        }
+    }
+
     public function getList() {
         try {
             $stmt = $this->db->prepare("select * from address");
20220126/address_delete.php
--- 20220126/address_delete.php
+++ 20220126/address_delete.php
@@ -1,16 +1,27 @@
+<script>
+    let deleteConfirm = confirm("Are You Sure?");
+</script>
 <?php
+
+    $deleteConfirm = "<script>document.write(deleteConfirm);</script>";
+    print($deleteConfirm);
     require_once("Address.php");
 
     $no = $_GET['no'];
 
     $address = new Address();
 
-    $result = $address->deleteTest($no);
-    if($result) {
-        echo "<script>alert('Delete Success!!!')</script>";
-        echo "<script>document.location.href='address_view.php'</script>";
-    }else {
-        echo "<script>alert('Delete Fail!!!')</script>";
-        echo "<script>document.location.href='address_view.php'</script>";
-    }
 
+
+    if($deleteConfirm == TRUE){
+        $result = $address->deleteTest($no);
+        if($result) {
+            echo "<script>alert('Delete Success!!!')</script>";
+            echo "<script>document.location.href='address_view.php'</script>";
+        }else {
+            echo "<script>alert('Delete Fail!!!')</script>";
+            echo "<script>document.location.href='address_view.php'</script>";
+        }
+    }else{
+
+    }
20220126/address_update_front.php
--- 20220126/address_update_front.php
+++ 20220126/address_update_front.php
@@ -1,3 +1,8 @@
+<?php
+    require_once("Address.php");
+    $address = new Address();
+    $list = $address->getListWhere($_GET['no']);
+?>
 <!doctype html>
 <html lang="ko">
 <head>
@@ -10,27 +15,27 @@
 <body>
     <form action="address_update_back.php?no=<?php echo $_GET['no'] ?>" method="post">
         <label for="name">
-            이름 : <input type="text" name="name" size="5">
+            이름 : <input type="text" name="name" size="5" value="<?php echo $list[0][1]; ?>">
         </label>
         <label for="age">
-            나이 : <input type="text" name="age" size="2">
+            나이 : <input type="text" name="age" size="3" value="<?php echo $list[0][2]; ?>">
         </label>
         <label for="tel">
-            연락처 : <input type="text" name="tel" size="8">
+            연락처 : <input type="text" name="tel" size="10" value="<?php echo $list[0][3]; ?>">
         </label><br>
         <label for="area">
             거주지 :
-            <select name="area">
-                <option value="광주">광주</option>
-                <option value="서울">서울</option>
-                <option value="대전">대전</option>
-                <option value="전주">전주</option>
-                <option value="부산">부산</option>
-                <option value="울산">울산</option>
+            <select name="area" "<?php echo $list[0][4]; ?>">
+                <option value="광주" <?php if($list[0][4] == '광주') echo 'selected'; ?>>광주</option>
+                <option value="서울" <?php if($list[0][4] == '서울') echo 'selected'; ?>>서울</option>
+                <option value="대전" <?php if($list[0][4] == '대전') echo 'selected'; ?>>대전</option>
+                <option value="전주" <?php if($list[0][4] == '전주') echo 'selected'; ?>>전주</option>
+                <option value="부산" <?php if($list[0][4] == '부산') echo 'selected'; ?>>부산</option>
+                <option value="울산" <?php if($list[0][4] == '울산') echo 'selected'; ?>>울산</option>
             </select>
         </label>
         <label for="birth">
-            생년월일 : <input type="date" name="birth">
+            생년월일 : <input type="date" name="birth" value="<?php echo $list[0][5]; ?>">
         </label>
         <br><button type="submit">수정</button>
     </form>
20220126/address_view.php
--- 20220126/address_view.php
+++ 20220126/address_view.php
@@ -3,7 +3,7 @@
     $address = new Address();
     $list = $address->getList();
 
-    $count = 0;
+//    $count = 0;
 ?>
 <!doctype html>
 <html lang="ko">
Add a comment
List