为什么我的留言本总是无法留言不成功? 不给出代码谁知道什么原因??按你所给出的条件,也只能推断大概是提交表单的HTML代码出错了~~ 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 <? if($action == "дºÃÁË!") { if( $name == " " || $msg ==" " ) { //------------[ 1] echo"<html>\n"; echo"<head>\n"; echo"<title>³ö´íÁË</title>\n"; echo"</head>\n"; echo"<body bgcolor=#ffcc99><center>\n"; echo"<h1>出错了</h1>\n"; echo"<p><font color = red>信息不全!昵称和内容是必须填写的!</font></p>\n"; echo"<a href=\"javascript:history.go(-1)\">请重试</a>\n"; echo"</center></body>\n"; echo"</html>\n"; } else { //-----------[ 2] $connection = @mysql_connect("localhost","root", "716118wxy") or die("无法连接到数据库!"); @mysql_select_db("guest") or die ( "选择数据库失败!"); $query = "insert into guestbook(name, time, msg, email) "; $query.="values('$name',NULL,'$msg', 'email')"; $result =@mysql_query( $query, $connnection ) or die ("存入数据库失败!"); mysql_close( $connection ) or die ("关闭数据库失败!"); echo"<html>\n"; echo"<head>\n"; echo"<title>成功了!</title>\n"; echo"</head>\n"; echo"<body bgcolor=#ffcc99><center>\n"; echo"<h1><font color = blue >填写留言成功!</font></h1>\n"; echo"<meta http-equiv=\"Refresh\" content=\"5; url=index.php\">"; echo"<h3>五秒钟后自动返回</h3>\n"; echo"<a href = index.php>立刻返回</a>"; echo"</center></body>\n"; echo"<html>"; } } else if( $action == "放弃")// ------------[ 3] { echo"<meta http-equiv=\"refresh\" content=\"0; url =index.php\">"; } else { if( $action == "reply" ) { //-------------[ 4] $connection = @mysql_connect("localhost", "root", "716118wxy") or die ("无法连接到数据库!"); @mysql_select_db("guest") or die("选择数据库失败!"); $query = "select name,msg FROM guestbook "; $query.="where serial=$serial"; $result = @mysql_query($query, $connection) or die("选择失败!"); $row = mysql_fetch_array( $result ); mysql_close( $connection ) or die (" 关闭数据库失败!"); $text = "\n\n[ÔÚ".$row[name]."的留言中提到\n".$row[msg]; } //-------------[ 5]?> <html><head><title>签写留言</title></head><body bgcolor=#ffcc99><center><h1><font color=blue>写留言</font></h1></cente><table border=0 cellpadding=10 align=center> <td> <form method=POST action="<? echo " $PHP_SELF?action=$action"; ?>"> 昵称:<input type =text name="name" maxlength="20"><br> Email:<input type="text" name=email maxlength="30"><br> 内容:<br> <textarea name="msg" rows="8" cols="60"><? echo $text; ?></textarea><br> <input type="submit" name="action" value="写好了!"> <input type=reset value="重写"> <input type=submit name=action value="放弃"> </form> </td></table></body></html><? }?> <? if($_GET['action'] == "") { if( $_POST['name'] =="" || $_POST['msg'] =="" ) { //------------[ 1] echo"<html>\n"; echo"<head>\n"; echo"<title>信息不全!昵称和内容是必须填写的!</title>\n"; echo"</head>\n"; echo"<body bgcolor=#ffcc99><center>\n"; echo"<h1>出错了</h1>\n"; echo"<p><font color = red>信息不全!昵称和内容是必须填写的!</font></p>\n"; echo"<a href=\"javascript:history.go(-1)\">请重试</a>\n"; echo"</center></body>\n"; echo"</html>\n"; } else { //-----------[ 2] $connection = @mysql_connect("localhost","root", "716118wxy") or die("无法连接到数据库!"); @mysql_select_db("guest") or die ( "选择数据库失败!"); $query = "insert into guestbook(name, time, msg, email) "; $query.="values({$_POST['name']},{time()},{$_POST['msg']},{$_POST['email']})"; $result =@mysql_query( $query, $connnection ) or die ("存入数据库失败!"); mysql_close($connection ) or die ("关闭数据库失败!"); echo"<html>\n"; echo"<head>\n"; echo"<title>成功了!</title>\n"; echo"</head>\n"; echo"<body bgcolor=#ffcc99><center>\n"; echo"<h1><font color = blue >填写留言成功!</font></h1>\n"; echo"<meta http-equiv=\"Refresh\" content=\"5; url=index.php\">"; echo"<h3>五秒钟后自动返回</h3>\n"; echo"<a href = index.php>立刻返回</a>"; echo"</center></body>\n"; echo"<html>"; } } else if( $action == "放弃")// ------------[ 3] { echo"<meta http-equiv=\"refresh\" content=\"0; url =index.php\">"; } else { if( $action == "reply" ) { //-------------[ 4] $connection = @mysql_connect("localhost", "root", "716118wxy") or die ("无法连接到数据库!"); @mysql_select_db("guest") or die("选择数据库失败!"); $query = "select name,msg FROM guestbook "; $query.="where serial=$serial"; $result = @mysql_query($query, $connection) or die("选择失败!"); $row = mysql_fetch_array( $result ); mysql_close( $connection ) or die (" 关闭数据库失败!"); $text = "\n\n[ÔÚ".$row[name]."的留言中提到\n".$row[msg]; } //-------------[ 5]?> <html><head><title>签写留言</title></head><body bgcolor=#ffcc99><center><h1><font color=blue>写留言</font></h1></cente><table border=0 cellpadding=10 align=center> <td> <form method=POST action="<? echo $PHP_SELF."?action=".$action; ?>"> 昵称:<input type =text name="name" maxlength="20"><br> Email:<input type="text" name="email" maxlength="30"><br> 内容:<br> <textarea name="msg" rows="8" cols="60"><? echo $text; ?></textarea><br> <input type="submit" name="action" value="写好了!"> <input type=reset value="重写"> <input type=submit name=action value="放弃"> </form> </td></table></body></html><? }?> 谢谢您,这问题困扰我好几天了,我还以为是我MYSQL数据库安装时候的问题呢,弄得我这几天郁闷的要死~~~再次感谢您~~~ socket 问题 php需要会linux,那么linux需要去到何种层度? 希望能请PHP高手帮忙解密一段代码,谢谢。 有人做过facebook application的开发吗? mysql数据库中的十进位是什么意思? 无法运行php呀!怎样才能重新运行或配置呀!进入主页全是乱码!急!!! 求正则表达式一条 为什么PHP生成的图片不能正常显示 WIN2000SERVER+PHP的INTRANET,请给建议 对话框 分数不够再加,请教问题定单查询 >>>>>>>>>请教个DATE的问题,大虾指教一下>>>>>>>
if($action == "дºÃÁË!")
{
if( $name == " " || $msg ==" " )
{
//------------[ 1]
echo"<html>\n";
echo"<head>\n";
echo"<title>³ö´íÁË</title>\n";
echo"</head>\n";
echo"<body bgcolor=#ffcc99><center>\n";
echo"<h1>出错了</h1>\n";
echo"<p><font color = red>信息不全!昵称和内容是必须填写的!</font></p>\n";
echo"<a href=\"javascript:history.go(-1)\">请重试</a>\n";
echo"</center></body>\n";
echo"</html>\n";
}
else
{
//-----------[ 2]
$connection = @mysql_connect("localhost","root", "716118wxy") or die("无法连接到数据库!");
@mysql_select_db("guest") or die ( "选择数据库失败!");
$query = "insert into guestbook(name, time, msg, email) ";
$query.="values('$name',NULL,'$msg', 'email')";
$result =@mysql_query( $query, $connnection ) or die ("存入数据库失败!");
mysql_close( $connection ) or die ("关闭数据库失败!");
echo"<html>\n";
echo"<head>\n";
echo"<title>成功了!</title>\n";
echo"</head>\n";
echo"<body bgcolor=#ffcc99><center>\n";
echo"<h1><font color = blue >填写留言成功!</font></h1>\n";
echo"<meta http-equiv=\"Refresh\" content=\"5; url=index.php\">";
echo"<h3>五秒钟后自动返回</h3>\n";
echo"<a href = index.php>立刻返回</a>";
echo"</center></body>\n";
echo"<html>";
}
}
else if( $action == "放弃")// ------------[ 3]
{
echo"<meta http-equiv=\"refresh\" content=\"0; url =index.php\">";
}
else
{
if( $action == "reply" )
{
//-------------[ 4]
$connection = @mysql_connect("localhost", "root", "716118wxy") or die ("无法连接到数据库!");
@mysql_select_db("guest") or die("选择数据库失败!");
$query = "select name,msg FROM guestbook ";
$query.="where serial=$serial";
$result = @mysql_query($query, $connection) or die("选择失败!");
$row = mysql_fetch_array( $result );
mysql_close( $connection ) or die (" 关闭数据库失败!");
$text = "\n\n[ÔÚ".$row[name]."的留言中提到\n".$row[msg];
}
//-------------[ 5]
?>
<html>
<head>
<title>签写留言</title>
</head><body bgcolor=#ffcc99>
<center><h1><font color=blue>写留言</font></h1></cente>
<table border=0 cellpadding=10 align=center>
<td>
<form method=POST action="<? echo " $PHP_SELF?action=$action"; ?>">
昵称:<input type =text name="name" maxlength="20"><br>
Email:<input type="text" name=email maxlength="30"><br>
内容:<br>
<textarea name="msg" rows="8" cols="60"><? echo $text; ?></textarea><br>
<input type="submit" name="action" value="写好了!">
<input type=reset value="重写">
<input type=submit name=action value="放弃">
</form>
</td>
</table>
</body>
</html>
<?
}
?>
if($_GET['action'] == "")
{
if( $_POST['name'] =="" || $_POST['msg'] =="" )
{
//------------[ 1]
echo"<html>\n";
echo"<head>\n";
echo"<title>信息不全!昵称和内容是必须填写的!</title>\n";
echo"</head>\n";
echo"<body bgcolor=#ffcc99><center>\n";
echo"<h1>出错了</h1>\n";
echo"<p><font color = red>信息不全!昵称和内容是必须填写的!</font></p>\n";
echo"<a href=\"javascript:history.go(-1)\">请重试</a>\n";
echo"</center></body>\n";
echo"</html>\n";
}
else
{
//-----------[ 2]
$connection = @mysql_connect("localhost","root", "716118wxy") or die("无法连接到数据库!");
@mysql_select_db("guest") or die ( "选择数据库失败!");
$query = "insert into guestbook(name, time, msg, email) ";
$query.="values({$_POST['name']},{time()},{$_POST['msg']},{$_POST['email']})";
$result =@mysql_query( $query, $connnection ) or die ("存入数据库失败!");
mysql_close($connection ) or die ("关闭数据库失败!");
echo"<html>\n";
echo"<head>\n";
echo"<title>成功了!</title>\n";
echo"</head>\n";
echo"<body bgcolor=#ffcc99><center>\n";
echo"<h1><font color = blue >填写留言成功!</font></h1>\n";
echo"<meta http-equiv=\"Refresh\" content=\"5; url=index.php\">";
echo"<h3>五秒钟后自动返回</h3>\n";
echo"<a href = index.php>立刻返回</a>";
echo"</center></body>\n";
echo"<html>";
}
}
else if( $action == "放弃")// ------------[ 3]
{
echo"<meta http-equiv=\"refresh\" content=\"0; url =index.php\">";
}
else
{
if( $action == "reply" )
{
//-------------[ 4]
$connection = @mysql_connect("localhost", "root", "716118wxy") or die ("无法连接到数据库!");
@mysql_select_db("guest") or die("选择数据库失败!");
$query = "select name,msg FROM guestbook ";
$query.="where serial=$serial";
$result = @mysql_query($query, $connection) or die("选择失败!");
$row = mysql_fetch_array( $result );
mysql_close( $connection ) or die (" 关闭数据库失败!");
$text = "\n\n[ÔÚ".$row[name]."的留言中提到\n".$row[msg];
}
//-------------[ 5]
?>
<html>
<head>
<title>签写留言</title>
</head><body bgcolor=#ffcc99>
<center><h1><font color=blue>写留言</font></h1></cente>
<table border=0 cellpadding=10 align=center>
<td>
<form method=POST action="<? echo $PHP_SELF."?action=".$action; ?>">
昵称:<input type =text name="name" maxlength="20"><br>
Email:<input type="text" name="email" maxlength="30"><br>
内容:<br>
<textarea name="msg" rows="8" cols="60"><? echo $text; ?></textarea><br>
<input type="submit" name="action" value="写好了!">
<input type=reset value="重写">
<input type=submit name=action value="放弃">
</form>
</td>
</table>
</body>
</html>
<?
}
?>