2012年9月16日
我纠结了很长时间终于决定开始写个程序..
现在程序的一个页面已经建立出来 当然是最简单的页面..
现在贴几个重要的代码..
数据库连接代码..
<?php
/*
* Msay Mongolia BBs
* Programmer : E-mail/QQ mfreezy@yahoo.cn (407443422)
* Mongol Mongolooroo baih boln bosoo Mongol
*
*/
$conn = @ mysql_connect("localhost", "root", "") or die("数据库链接错误");
mysql_select_db("bbs", $conn);
mysql_query("set names 'GBK'"); //使用GBK中文编码;
function htmtocode($content) {
$content = str_replace( "\r\n", "<br>", str_replace( " ", " ", $content));
return $content;
}
//$content=str_replace("'","‘",$content);
//htmlspecialchars();
?>
添加留言代码
<link href="images/css.css" rel="stylesheet" type="text/css">
<?php
/*
* PHP100Job v1.0
* Programmer : Msn/QQ haowubai@hotmail.com (925939)
* www.php100.com Develop a project PHP - MySQL - Apache
* Window 2003 - Preferences - PHPeclipse - PHP - Code Templates
*/
include("conn.php");
if($_POST['submit']){
$sql="insert into message (id,user,title,content,lastdate) " .
"values ('','$_POST[user]','$_POST[title]','$_POST[content]',now())";
mysql_query($sql);
echo "<script language=\"javascript\">alert('添加成功');history.go(-1)</script>";
}
?>
<SCRIPT language=javascript>
function CheckPost()
{
if (myform.user.value=="")
{
alert("请填写用户名");
myform.user.focus();
return false;
}
if (myform.title.value.length<5)
{
alert("标题不能少于5个字符");
myform.title.focus();
return false;
}
if (myform.content.value=="")
{
alert("必须要填写留言内容");
myform.content.focus();
return false;
}
}
</SCRIPT>
<form action="add.php" method="post" name="myform" onSubmit="return CheckPost();">
<table>
<tr><td width="20" height="540"class="info1"> </td>
<td>
<table width="20" height="540"border="0" border="0"border="2">
<tr><td> </td>
<td class="info"> </td>
<td><input type="text" name="user" maxlength="20" size="50" tabindex="2" class="Nertextarea">
</td>
<td class="info"> :</td>
<td class="Nertextarea"><input type="text" name="title" maxlength="20" size="50" tabindex="2" class="Nertextarea"> </td>
<td class="info">
</td>
<td>
<textarea type="text" name="content" class="textarea" style={ table-layout:fixed;
word-wrap:break-word;}cols="75" rows="10" tabindex="2" ></textarea>
</td>
<td height="545">
<input type="submit" name="submit" class="Nertextarea"value=""/>
</form>