//========================== if (strcmp($_POST['key'], $key) != 0) { echo "key err"; return; } if (strcmp($_POST['cmd'], "read") == 0) { echo read(); } if (strcmp($_POST['cmd'], "add") == 0) { echo add_data(); } if (strcmp($_POST['cmd'], "del") == 0) { echo remove_data(); } if (strcmp($_POST['cmd'], "edit") == 0) { echo edit_data(); } /*if(strcmp($_POST['cmd'],"res")==0) reset_data(); if(strcmp($_POST['cmd'],"show")==0) echo show_data();*/ function is_in_group($uid, $gid) { global $group; $scan = array($gid); //the queue of gid that must be scanned for ($idx = 0; $idx < count($scan); ++$idx) { $arr = $group[$scan[$idx]]; //current scaned group for ($i = 0, $N = count($arr); $i < $N; ++$i) { $k = $arr[$i];
<?php ob_start(); if ($_REQUEST['edit']) { edit_data($_REQUEST['id']); /* функция обработки */ } ?> <?php foreach ($posts as $post) { ?> <!--начали перебор массива--> <form action="" method="POST" name="edit_data"> <table> <tr> <td>Заголовок: </td> <td><input type="text" name="title" value="<?php echo $post['title']; ?> "></td> </tr> <tr> <td>Дата: </td> <td><input type="text" name="date" value="<?php echo $post['date']; ?> "></td> </tr>
$error = ''; $id = $_GET['id']; if (isset($_GET['id'])) { $article = tampilkan_per_id($id); while ($row = mysqli_fetch_assoc($article)) { $judul_awal = $row['judul']; $konten_awal = $row['isi']; $tag_awal = $row['tag']; } } if (isset($_POST['submit'])) { $judul = $_POST['judul']; $konten = $_POST['konten']; $tag = $_POST['tag']; if (!empty(trim($judul)) && !empty(trim($konten))) { if (edit_data($judul, $konten, $tag, $id)) { header('Location: index.php'); //akan menuju halaman index } else { $error = 'Ada masalah saat menambah data'; } } else { $error = 'Judul dan konten harus diisi!'; } } ?> <form action="" method="post"> <label for="judul">Judul</label>