源代码如下:
<html>
<head>
<title>发表文章</title>
</head>
<body bgcolor="#ffffff" vlink="#e5724f" link="#ff0000" text="2f2f4f">
<?php
//连接数据库服务器,为后面的工作做准备
mysql_connect("127.0.0.1","root","");
mysql_select_db("web_db");//检查文章信息是否全面,如果不全面,则返回给用户,要求重新填写
if(($subject=="")||($author=="")||($contents==""))
{
?>
<blockquote><blockquote>
<center>
<font size="+2">发表文章</font>
<hr></center>
<form method=post action="post.php">
标题:<input type=text name=subject size=20
<?php
//如果要发表的文章是给别人的回复,则查找原来文章的标题
//在前面添加"Re:"标记,作为新文章的标题
if($id)
{
$query="select subject from guestbook where id='$id'";
$result=mysql_query($query);
if(mysql_num_rows($result))
$arr=mysql_fetch_array($result);
$subject="Re:".$arr['subject'];
}

echo "value='$subject'";
?>
><br>
姓名:<input type=text name=author size=20
<?php
//以下信息如果用户已经填写,则按照原来的内容填写回去
echo $author;
?>><br>
电子邮件:<input type=text name=email size=20
<?php
echo $email;
?>><p>
文章内容:<br>
<?php
echo "<textarea name=contents cols=50 rows=6>";
echo $contents;
echo "</textarea><p>";
?>
<input type=submit value=提交> <input type=reset value=重写>
</form>

<p>请勿多次提交,否则您的文章将重复出现。
<hr>
<center>返回<a href="list.php">文章列表</a><br></center>
</blockquote></blockquote>

<?php
}
else{
//如果用户提交的信息符合条件,则把文章存入数据表中
$date=date("Y-m-d H:i:s");
$query="insert into guestbook values(,'$subject','$author','$email','$date','$contents')";
mysql_query($query);

//如果出错,则报告出错信息;否则,报告成功信息
if(mysql_errno())
{
echo "<center><br><h3>";
echo "您的文章无法写入MySQL数据库,请联系";
echo "<a href='mailto:[email protected]'>站长";
echo "</a></h3></center>";
}
else
{
echo "<center><br><h3>祝贺您,您的文章已经成功记录!</h3><br>";
echo "<br><br>返回<a href='list.php'>文章列表</a><br></center>";
}
}
?>
</body>
</html>

解决方案 »

  1.   

    if($_REQUEST['sumit']="提交"){
    $subject=$_POST['subject'];
    $author=$_POST['author'];
    $contents$_POST['contents'];
    if(($subject=="")||($author=="")||($contents=="")){
    echo "你没有填写完整";
    exit();
    }
    ///////////////////////////////
    插入数据库
    }
      

  2.   

    开头加上
    error_reporting(E_ALL^E_NOTICE);
    再看看什么错误,你的变量都没有初始化,肯定一堆notice的
      

  3.   

    if(($subject=="")||($author=="")||($contents==""))
    {
    =>
    if (!empty($_POST['submit']))
    {  
       extract($_POST);