<?php
include "conn.php";
include "head.php";
if($_POST['submit']){
$sql = "insert into message(user,title,content,lastdate)" .
"values('$_POST[user]','$_POST[title]','$_POST[content]',now())";
mysql_query($sql);
echo '<script type="text/javascript">alert("发布成功!");</script>';
}
?>
<script type="text/javascript">
function checkPost(){
if(myform.user.value==""){
alert("请输入用户名!");
myform.user.focus();
return;
}
if(myform.title.value.length<5){
alert("标题不少于5个字符。");
myform.title.focus();
return;
}
}
</script>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<form action="add.php" method="post" name="myform" onsubmit="checkPost();">
用户:<input type="text" size="10" name="user" /><br/>
标题:<input type="text" name="title" /><br/>
内容:<textarea rows="10" cols="50" name="content"> </textarea><br/>
<input type="submit" name="submit" value="发表留言" />
</form>
- 1
- 2
前往页