源代码如下:
<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>
<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>
解决方案 »
- 下载问题,小文件下载正常,下载大于100M的文件,进度条到100M以外的时候,进度条就不走了,代码什么地方出问题了?
- 初学PHP,请教大家嵌套很多单引号 双引号 大括号 要怎么写?
- 如何查找当前的网段?
- 菜鸟问个问题,关于phpnow 安装失败
- 用户登录2次才能成功,请教
- 用过XAJAX的来帮忙下。
- 100分请教一个初级的apache重写
- 求一个不许要验证的SMTP服务器
- 初级问题2,回答对了我马上给分
- 关于Access denied for user 'root'@'localhost' (using password: NO)
- php中有没有得到昨天时间串的函数???
- PHP5扩展MYSQL问题!搞了一个星期还不行!我要崩溃了!救命!
$subject=$_POST['subject'];
$author=$_POST['author'];
$contents$_POST['contents'];
if(($subject=="")||($author=="")||($contents=="")){
echo "你没有填写完整";
exit();
}
///////////////////////////////
插入数据库
}
error_reporting(E_ALL^E_NOTICE);
再看看什么错误,你的变量都没有初始化,肯定一堆notice的
{
=>
if (!empty($_POST['submit']))
{
extract($_POST);