echo "<hr><br>";
$row=mysql_fetch_row($result);
}
mysql_close($link);
?>
<form method="POST" action="InsetToDB.php">
昵称:<input type="text" size="8"; name="name">
<p>内 www.dd951.com 容:<textarea rows="5" name="text" cols="60"></textarea>
</p>
<p><input type="submit" value="提交" name="B1"><input type="reset" value="重置"
name="B2"></p>
</form>
InsetToDB.php 的代码:
复制代码代 www.515tg.com 码如下:
<?php
include("IncDB.php");
$name=addslashes($_POST['name']);
//addslashes -- 字符串 www.fuweitek.com 加入斜线 string
addslashes(string str);
$text=addslashes($_POST['text']);
$sql = "INSERT INTO `intd` (`id`, `name`, `text`, `datetime`) VALUES (NULL, '$name', '$text',
now());";
//$sql="INSERT INTO `intd` ( , `name` , `text`,`datetime` ) VALUES ( ,'$name','$text',now())";
if(mysql_query($sql,$link))
{
echo "留 www.kshyf.com 言成 www.szhrtz.com 功!";
echo "<meta http-equiv=\"refresh\" content=\"1;URL=index.php\">";
}
else
echo "留 www.penqiang.net 言失败!";
mysql_close($link);
?>
PHP
中的 addslashes 函数
addslashes -- 字符串加入斜线。
语法: string addslashes(string str);
内容说 www.ksjian888.com 明