图片演示:
代码如下:
<?php
function ReShowInfo($str)
{
$str = stripslashes($str);
$str = str_replace("<br />\r\n","<br />",htmlspecialchars(nl2br($str)));
return $str;
}
function ReIptInfo($str)
{
$str = stripslashes($str);
$str = str_replace("<br />","",htmlspecialchars(nl2br($str)));
return $str;
}
if($_POST["operation"] == "post")
{
echo ReShowInfo($_POST["t_content"]);
$content2 = ReIptInfo($_POST["t_content"]);
}
?>
<form method="post" action="">
标题:<input type="text" value="<?php echo ReShowInfo($_POST["t_content"]);?>"><br />
内容:<textarea name="t_content" colspan=50 rowspan=50><?php echo $content2;?></textarea><br />
<input type="submit" value="提交">
<input type="hidden" name="operation" value="post">
</form>
数据放入数据库和取出来显示在页面需要注意什么
入库时
$str=addslashes($str);
$sql="insert into `tab` (`content`) values('$str')";
出库时
$str=stripslashes($str);
显示时
$str=htmlspecialchars(nl2br($str)) ;
评论