<?php session_start(); require ('dbms.php'); if(!isset($_SESSION['login'])){ header('Location: index.php?login=noLOGIN'); exit(); } ?> <h2>Hello <?php echo $_SESSION['username']; ?> </h2> <h2>Edit Todolist</h2> <?php $sql_incom = "SELECT * FROM tb_note WHERE user_id = '".$_SESSION['id']."' AND id = '".$_GET['note_id']."' "; $result_incom = mysqli_query($conn,$sql_incom); if($result_incom->num_rows >0 ){ while($row = mysqli_fetch_assoc($result_incom)){ var_dump($row); echo '<form action="conedit.php" method="post">'; echo '<label>header: </label> <br>'; echo '<input type="text" name="header" value="'.$row["header"].'"> <br>'; echo '<label>detail: </label> <br>'; echo '<textarea type="text" name="detail" cols="66" rows="10">'.$row["detail"].'</textarea> <br>' ; echo '<label>priority:</label><br>'; echo '<input type="text" name="type" value="'.$row["type"].'"><br>'; echo '<input type="date" name ="time" value="'.$row["timee"].'"><br>'; echo '<input type="hidden" name="note_id" value="'.$row["id"].'">'; echo '<button type="edit" name="editbtn"> submit</button>'; echo '</form> '; } } ?>
<?php session_start(); require ('dbms.php'); if(!isset($_SESSION['login'])){ header('Location: index.php?login=noLOGIN'); exit(); } ?> <h2>Hello <?php echo $_SESSION['username']; ?> </h2> <h2>Add Todolist</h2> <form action="conadd.php" method="post"> <label>header: </label> <br> <input type="text" name="header" > <br> <label>detail: </label> <br> <textarea type="text" name="detail" ></textarea> <br> <label>priority:</label><br> <input type="text" name="type" ><br> <input type="date" name ="time" ><br> <button type="submit" name="addtask"> submit</button> </form> <hr> <?php $sql_incom = "SELECT * FROM tb_note WHERE user_id = '".$_SESSION['id']."' "; $result_incom = mysqli_query($conn,$sql_incom); if($result_incom->num_rows >0 ){ while($row = mysqli_fetch_assoc($result_incom)){ echo "<li>"; echo '<input type="checkbox"><label>'.$row["header"].'</label><input type="text">'; echo $row["detail"]; echo $row["type"]; echo $row["timee"]; ?> <a href="editpage.php?note_id=<?php echo $row["id"]; ?>"> Edit</a> <?php echo "</li>"; } } ?> <a href="logout.php">Logout </a>
<?php session_start(); include ('dbms.php'); if(isset($_POST['editbtn'])){ $id = $_POST['note_id']; $header =$_POST['header']; $detail =$_POST['detail']; $time = $_POST['time']; $type = $_POST['type']; if($header =="" || $detail == "" || $type =="" ){ header('Location: home.php?note=fail'); exit(); } //$user_id = $_SESSION['id']; $sql_comm = "UPDATE tb_note SET header = '$header', detail ='$detail', timee = '$time', type = '$type', WHERE id = '$id';"; if ($conn->query($sql_comm) === TRUE) { header('location: home.php?add=true'); exit(); } else { echo "Error ".$sql_comm ; } } ?>
if ($conn->query($sql_comm) === TRUE) { if($conn->affected_rows>0){ header('location: home.php?add=true'); exit(); }else{ die($sql_comm); // ตรวจสอบ statement ให้ดี } }
เพื่อความปลอดภัยของเว็บบอร์ด ไม่อนุญาติให้แทรก แท็ก [img]....[/img] โดยการอัพโหลดไฟล์รูปจากที่อื่น เช่นเว็บไซต์ ฟรีอัพโหลดต่าง ๆ อัพโหลดแทรกรูปภาพ ให้ใช้บริการอัพโหลดไฟล์ของไทยครีเอท และตัดรูปภาพให้พอดีกับสกรีน เพื่อความโหลดเร็วและไฟล์ไม่ถูกลบทิ้ง