我建立了小型内容管理系统。 我们现在要提的问题
I m 过滤站,其职能如下:
function filter($data, $db)
{
$data = trim(htmlentities(strip_tags($data)));
if (get_magic_quotes_gpc())
$data = stripslashes($data);
$data = $db->escape_string($data);
return $data;
}
而《公共卫生法》则认为
$name=filter($_POST[ name ], $db);
$title=filter($_POST[ title ], $db);
$parent=filter($_POST[ parent ],$db);
$switch=filter($_POST[ switch ], $db);
if($switch= ){
echo "Return back and select an option";
die();
}
$parentcheck=filter($_POST[ parentcheck ],$db);
if($parentcheck== 0 )
{
$parent=$parentcheck;
}
$purifier = new HTMLPurifier();
$content = $db->real_escape_string( $purifier->purify( $_POST[ content ]) );
if(isset($_POST[ submit ])&&$_POST[ submit ]== Ok ){
$result=$db->query("INSERT INTO menu (parent, name, showinmenu) VALUES ( $parent , $name , $switch ") or die($db->error);
$result2=$db->query("INSERT INTO pages (id, title, content) VALUES ( <what?> , $title , $content ") or die($db->error);
}
我的表象
Table named "pages"
而“男性”
www.un.org/Depts/DGACM/index_spanish.htm 我的问题如下:。
I m trying to get autoincremented
id
value frommenu
table after( $parent , $name , $switch ")
insertion and set thisid
inpages
table while inserting ($title, $content). How to do it? Is it possible with single query?$content
s value is the text with HTML tags. I m using html purifier. May I filter it s value too before inserting into db table? Any suggestion/advice?