$query = "SELECT * FROM articles WHERE id_article=\"$editid\"";
$edited = $db->query($query)->fetch_object();
echo "<form action=\"\" method=\"post\" id=\"add_article\" >";
echo "ID menu <select name=\"urlmenu\" form=\"add_article\">";
$query = "SELECT id_menuitem,url,name FROM menu_item";
$result =$db->query($query);
while ($obj = $result->fetch_object()) {
echo "<option value=\"$obj->id_menuitem\">$obj->name</option>";
}
echo "</select></br>";
echo "Name <input type=text name=name value='$edited->name'></br>";
echo "Perex <input type=text name=perex value='$edited->perex'></br>";
echo "Keywords <input type=text name=keywords value='$edited->keywords'></br>";
echo "<textarea name=content cols=100 rows=20>$edited->content</textarea><br>";
echo '<input type=submit value=Edit name=editstate>';
echo "<input type=hidden value=$editid name=id>";
echo '</form>';
if (isset($_POST["editstate"]))
{
$b = false;
$perex = addslashes($_POST["perex"]);
$content = addslashes($_POST["content"]);
$name = addslashes($_POST["name"]);
$id = addslashes($_POST["id"]);
echo var_dump($_POST);
$query = "UPDATE articles SET perex=\"$perex\", content=\"$content\", name=\"$name\" WHERE id_article = $id";
$db->query($query);
}
我想通过post方法发送表单数据,除了textarea之外一切正常。
vardump
始终显示为空
array(7) { ["urlmenu"]=> string(1) "1" ["name"]=> string(4) "Abcd" ["perex"]=> string(4) "Dfeg" ["keywords"]=> string(4) "Hjkl" ["editstate"]=> string(4)
"Edit" ["id"]=> string(1) "5" **["content"]=> string(0)** "" }
我还尝试将"form"
属性添加到textarea,但结果始终相同
答案 0 :(得分:0)
好吧,这是一个愚蠢的错误,我有两个同名的表格。