html留言板

html-css011

html留言板,第1张

<?php

//开启SESSION,启用SESSION变量检查表单是否重复提交

session_start()

$title="留言"

include("include/header.php")

include("include/class.imobj.php")//检查表单,符合要求的留言插入数据库

$sub=$_POST['sub']//防止恶意留言代码并规划文本格式

function clean($string){

$string = stripslashes($string)

$string = addslashes($string)

$string = htmlspecialchars($string)

$string = strip_tags($string)

$string = trim($string)

$string = nl2br($string)

$string = substr($string,0,250)

return $string

}

//判断表单

if (!empty($_POST['name'])&&!empty($_POST['email'])&&!empty($_POST['message'])&&$_SESSION["userlastaction"]<$_POST["lastaction"]) {

if (!strcasecmp($_POST['checknum'],$_SESSION['chenknum'])){

$name=clean($_POST['name'])

$email=clean($_POST['email'])

$message=clean($_POST['message'])

$_SESSION["userlastaction"]++

/*

include("include/conn_ruin.php")

$sql = "INSERT INTO guestbook (name,time_at,email,message) VALUES('$name',NOW( ),'$email','$message')"

$result = @mysql_query($sql,$conn)

mysql_close($conn)

*/

$error = 'Now , the message page isn\'t opening until i let it open! you can do anything if you can , trash!,'

}else {

$error = "出错:验证码错误! Warning: Authentication code error!"

}

}else {

$error ="出错:您的表单没有填写完整或重复提交,请重新检查内容或浏览其它感兴趣的页面!  Warning:You did not fill out forms, or to repeat. Please check. Or visit other pages!"

}//验证码部分

$check = new imobj()

$check->construct()

$check->createimg()

$_SESSION['chenknum'] = $check->getid()?>

<body id="me">

<div id="menu">

<ul>

<li id="home"><a href="home.php" title="首页">HOME</a></li>

<li id="blog"><a href="blog.php" title="博客">BLOG</a></li>

<li id="about"><a href="about.php" title="关于我">ABOUT</a></li>

<li id="message"><a href="message.php" title="给我留言">MESSAGE</a></li>

</ul>

</div>

<hr />

<div id="content">

<fieldset>

<div id="view"><?php if (!empty($error)&&$sub=="true") echo "<span style=\"color:#fffbackground:redfont-weight:boldfont-size:12px\" >$error</span>" ?>

<hr /> <?php

include("include/conn_ruin.php")//分页部分 //取得留言总条数

$sql = "SELECT COUNT(*) FROM guestbook"

$result=mysql_query($sql,$conn)

$mes_number = mysql_fetch_row($result)//设置每页显示条数

$every_number = 12

//获取最后的页数

$last_page_number = floor($mes_number[0] /$every_number)+1//获取当前所请求的页码

if (empty($_GET['page']) || $_GET['page']<1)

{

$page=1

} else if ($_GET['page']>$last_page_number)

{

$page=$last_page_number

}else {

$page = $_GET['page']

} //echo "everynumber:".$every_number."

".$last_page_number."

".$page//获取LIMIT参数

$a = ($page-1)*$every_number//echo "

$a"//读取数据库并显示留言 $sql ="SELECT * FROM guestbook ORDER BY time_at DESC LIMIT $a,$every_number"

$result=mysql_query($sql,$conn)

echo "<table>"

while($row = mysql_fetch_row($result))

{

echo "<tr class=\"title\"><td>"

echo "<b>".$row[1]."</b> | ".$row[2]."</td></tr>"

echo "<tr class=\"mess\"><td>"

echo $row[4]."</td></tr>"

}

echo "</table>"

mysql_close($conn)?>

</div>

<hr />

<a href="message.php?page=1">首页</a> <a href="message.php?page=<?=$page-1?>">上一页</a> <a href="message.php?page=<?=$page+1?>">下一页</a> <a href="message.php?page=<?=$last_page_number?>">末页</a>

<hr />

<div id="writein">

<h4>填写您的留言,如需站长回复,请务必填写您的真实E-Mail</h4>

<form name="test" onSubmit="return CheckForm()" action="message.php" method="post">

姓名[name]:<input type="text" name="name" maxlength=15 /> 邮箱[email]:<input type="text" name="email" maxlength=50 />

<p>留言[message]:验证 : <input type="text" size="6" name="checknum" /> <img src ="img.php" /></p>

<p><textarea cols="62" rows="5" name="message"></textarea></p>

<input type="hidden" name="sub" value="true" /><input type="hidden" name="lastaction" value=<?=$_SESSION["userlastaction"]+1 ?>/>

<input type="hidden" name="checknumc" value="<?=$numc?>" />

<p><input class="button" type="submit" value="提 交" /><input class="button" type="reset" value="重 写" /></p>

</form>

</div>

<hr />

</fieldset>

</div>

<?php include("include/footer.php") ?>

</body>

</html>很久以前写的一个PHP留言板,防不了垃圾留言

<html>

<head>

<meta http-equiv="Content-Type" content="text/htmlcharset=gb2312">

<title>留言板</title>

</head>

<body>

<table width="750" cellspacing="3" cellpadding="0" id="table1">

<tr>

<td width="250" bgcolor="#FFCCFF"> </td>

<td width="250" bgcolor="#CCFFCC"> </td>

<td width="250" bgcolor="#CCFFFF"> </td>

</tr>

<tr>

<td height="200" bgcolor="#FFCCFF"> </td>

<td height="200" width="250" style="border:1px red solid">

此处为留言板

<iframe name="I1" src="liuyan.asp" height="200" width="250" marginwidth="1" marginheight="1" scrolling="no" border="1" frameborder="1"></iframe>

<!--不要边框 frameborder="1",ASP制作的留言版src="liuyan.asp",要滚动条scrolling="yes"-->

</td>

<td height="200" bgcolor="#CCFFFF"> </td>

</tr>

<tr>

<td bgcolor="#FFCCFF"> </td>

<td bgcolor="#CCFFCC"> </td>

<td bgcolor="#CCFFFF"> </td>

</tr>

</table>

</body>

</html>

HTML 代码留言板 一个超简陋的留言版 免费留言板 //评论内容不能保存 因为涉及到数据库

<script>

function Ok_OnClick(event)

{

if(document.getElementsByName("textName")[0].value == ""){

alert("请输入内容")

return

}//getElementById

var table

var tableList = document.getElementsByTagName("TABLE")

for(var i = 0 i <tableList.length i++) {

if(tableList[i].name == "tableName") {

table = tableList[i]

break

}

}

var value = document.getElementsByName("textName")[0].value

var index = table.rows.length

table.insertRow(index)

table.rows(index).insertCell(0)

table.rows(index).cells(0).innerText = value

document.getElementsByName("textName")[0].value = ""

}

</script>

<HTML>

<HEAD>

<META http-equiv="Content-Type" content="text/htmlcharset=gb2312">

<TITLE>留言版</TITLE>

<STYLE>

td{width:20%height:20pxborder-bottom:1px solid blackborder-right:1px solid blackcursor:default}

div{font-size:13px}

th{height:20pxfont-size:12pxfont-weight:normalborder-bottom:2px solid blackbackground-color:#CCCCCC}

table{border:1px solid blackfont-size:13px}

</STYLE>

</HEAD>

<BODY oncontextmenu="return false"">

<TABLE name="tableName" width="70%" align="center" cellpadding="0" cellspacing="0">

<TR>

<TH colspan="4" style="">留言版</TH>

</TR>

<TR>

<TD>呵呵,一个超简陋的留言版 ^_^</TD>

</TR>

</TABLE>

<BR>

<div align="center">

<textarea rows="2" name="textName" id="textId" cols="20"

style="width: 70%clip: rect(0pt, 47pt, 18pt, 0pt)font-family: 宋体font-size: 10ptfont-weight: normalfont-style: normaltext-align: leftvertical-align: middletext-indent: 0color: #000000background-attachment: fixedbackground-color: #EEEEEEborder: 1px solid #0xf8f8f8">

</textarea>

</div>

<BR>

<div align="center">

<input type="button" value="提交" onclick="return Ok_OnClick(window.event)"

style="align:center width:60 height: 21clip: rect(0pt, 47pt, 18pt, 0pt)font-family: 宋体font-size: 10ptfont-weight: normalfont-style: normalcursor: handtext-align: centervertical-align: middletext-indent: 0color: #000000background-attachment: fixedbackground-color: #d8d8d8border: 1px solid #59b4f7">

<!--position: absoluteleft: 342top: 184-->

</div>

</BODY>

</HTML>