<?
if (!$login_status) {echo "对不起,您还未登录"; exit;}if ($job=="read") {
$sql = "SELECT sender,title,content,sendtime FROM message where id=$msg";
$result=$userdb->Execute($sql);
$author=$result->fields[0];
$title=$result->fields[1];
$content=$result->fields[2];
$ctime=$result->fields[3];
$ctime=date("Y-m-d H:i:s",$ctime);
echo "<div><center><a href=messager.php?job=receivebox target=msg><img src=images/inboxpm.gif border=0></a>
<a href=messager.php?job=write target=msg><img src=images/newpm.gif border=0></a>
<a href=messager.php?job=clear target=msg><img src=images/deletepm.gif border=0></a><a href='messager.php?job=write&target=$author'><img src=images/replypm.gif border=0></a></center>$ctime $title 发给你的信息<br><font color=333366>题目:</font>$title<br><br>$content<br><br></div>";
$result->close();
$sql = "UPDATE message SET flag='1' where id=$msg";
$userdb->Execute($sql);
}if ($job=="receivebox") {
echo<<<EOD
<table bgcolor=F3F3F3 width=100% border=0 cellspacing=0 cellpadding=2 >
<tr align=center bgcolor=#ffffff>
<td><a href="messager.php?job=receivebox" target=msg><img src=images/inboxpm.gif border=0></a>
<a href="messager.php?job=write" target=msg><img src=images/newpm.gif border=0></a>
<a href="messager.php?job=clear" target=msg><img src=images/deletepm.gif border=0></a>
</td>
</tr>
</table>
EOD;
$sql = "SELECT sender,title,flag,id,sendtime FROM message where incept='$articleusername' ORDER BY id DESC";
$result=$userdb->Execute($sql);
if(!$result->EOF){
echo<<<EOD
<table bgcolor=F3F3F3 width=100% border=0 cellspacing=0 cellpadding=2 align=center>
<tr align=center bgcolor=#f2f8ff>
<td width="67"><b><font color=444444>作者</font></b></td>
<td><b><font color=444444>题目</font></b></td>
<td width="26"><font color=333366>已读</font>
</td>
</tr></table>
EOD;
sline();
while (!$result->EOF){
$author=$result->fields[0];
$title=$result->fields[1];
$flag=$result->fields[2];
$id=$result->fields[3];
if($flag){
$isread="是";
}else{
$isread="否";
}
echo<<<EOD
<table width=100% border=0 cellspacing=0 cellpadding=2 align=center>
<tr align=center>
<td width="67"><acronym title='给用户发一个短信息'><a href='messager.php?job=write&target=$author'>$author</a></acronym></td>
<td><a href='messager.php?job=read&msg=$id'>$title</a></td>
<td width="26">$isread</td>
</tr></table>
EOD;
sline();
$result->MoveNext();
} }else{
echo "<br>$articleusername 您没有任何短消息"; exit;
}
$result->close();
}
if ($job=="write") {
if (empty($step)){
print_form();
}elseif($step==2){
if (empty($content) || empty($title) || empty($ruser)) {
echo "对不起,发生资料错误,请 <a href='javascript:history.back(1);'>返回检查</a>";
exit;
}
if (strlen($content)>200) {
echo "对不起,短消息内容不能超过200个字符,请 <a href='javascript:history.back(1);'>返回检查</a>";
exit;
}
$content.="\n<br><br>[来源:文章系统]";
$stime=date("Y-m-d H:i:s");
$title=textconvert($title);
$content=textconvert($content);
$sql="INSERT INTO message(sender,incept,title,content,flag,sendtime)VALUES('$articleusername','$ruser','$title','$content',0,'$stime')";
$addinfo=$userdb->Execute($sql);
if (!$addinfo) {
print '添加错误: '.$db->ErrorMsg().'<BR>';
}else{
echo "<br>已经完成,<a href='messager.php?job=receivebox'>点这里返回收件箱</a>";
exit;
}
}
}
if ($job=="clear") {
$sql="DELETE FROM message WHERE incept='$articleusername' and flag<>0";
$addinfo=$userdb->Execute($sql); if (!$addinfo) {
print '删除错误: '.$db->ErrorMsg().'<BR>';
}else{
echo "<br>您的所有短信息已被成功清空";
exit;
}
}function print_form() {
global $target;
echo<<<EOD
<table width=205 border=0 cellspacing=0 cellpadding=0>
<tr bgcolor=F3F3F3>
<td> 请填写信息</td>
</tr><form action=messager.php method=POST>
<tr bgcolor=#FFFFFF>
<td>
接收用户:
<input value='$target' style="background-color:#ffffff; color:#9999FF; border: 1 double #B4B4B4" onMouseOver = "this.style.backgroundColor = '#E5F0FF'" onMouseOut ="this.style.backgroundColor =''" type=text size=12 name="ruser"><br>
留言题目:
<input style="background-color:#ffffff; color:#9999FF; border: 1 double #B4B4B4" onMouseOver = "this.style.backgroundColor = '#E5F0FF'" onMouseOut ="this.style.backgroundColor =''" type=text size=38 name="title">
<br>
<textarea style="background-color:#ffffff; border: 1 double #B4B4B4" onMouseOver = "this.style.backgroundColor = '#f3f3f3'" onMouseOut = "this.style.backgroundColor = ''" name="content" cols=40 rows=3></textarea>
<br>
</td>
</tr>
<tr bgcolor=FFFFFF>
<td><input style="color: #000000; background-color: #f3f3f3; border-style: solid; border-width: 1" onMouseOver ="this.style.backgroundColor='#FFC864'" onMouseOut ="this.style.backgroundColor='#f3f3f3'" type=submit value="提 交">
<input type=hidden name=job value=write>
<input type=hidden name=step value=2>
</td>
</tr></form>
</table>
EOD;
}
给出一些代码,自己看看吧
不全,有些需要的没有给出,但是你说的已有了,你看看吧
if (!$login_status) {echo "对不起,您还未登录"; exit;}if ($job=="read") {
$sql = "SELECT sender,title,content,sendtime FROM message where id=$msg";
$result=$userdb->Execute($sql);
$author=$result->fields[0];
$title=$result->fields[1];
$content=$result->fields[2];
$ctime=$result->fields[3];
$ctime=date("Y-m-d H:i:s",$ctime);
echo "<div><center><a href=messager.php?job=receivebox target=msg><img src=images/inboxpm.gif border=0></a>
<a href=messager.php?job=write target=msg><img src=images/newpm.gif border=0></a>
<a href=messager.php?job=clear target=msg><img src=images/deletepm.gif border=0></a><a href='messager.php?job=write&target=$author'><img src=images/replypm.gif border=0></a></center>$ctime $title 发给你的信息<br><font color=333366>题目:</font>$title<br><br>$content<br><br></div>";
$result->close();
$sql = "UPDATE message SET flag='1' where id=$msg";
$userdb->Execute($sql);
}if ($job=="receivebox") {
echo<<<EOD
<table bgcolor=F3F3F3 width=100% border=0 cellspacing=0 cellpadding=2 >
<tr align=center bgcolor=#ffffff>
<td><a href="messager.php?job=receivebox" target=msg><img src=images/inboxpm.gif border=0></a>
<a href="messager.php?job=write" target=msg><img src=images/newpm.gif border=0></a>
<a href="messager.php?job=clear" target=msg><img src=images/deletepm.gif border=0></a>
</td>
</tr>
</table>
EOD;
$sql = "SELECT sender,title,flag,id,sendtime FROM message where incept='$articleusername' ORDER BY id DESC";
$result=$userdb->Execute($sql);
if(!$result->EOF){
echo<<<EOD
<table bgcolor=F3F3F3 width=100% border=0 cellspacing=0 cellpadding=2 align=center>
<tr align=center bgcolor=#f2f8ff>
<td width="67"><b><font color=444444>作者</font></b></td>
<td><b><font color=444444>题目</font></b></td>
<td width="26"><font color=333366>已读</font>
</td>
</tr></table>
EOD;
sline();
while (!$result->EOF){
$author=$result->fields[0];
$title=$result->fields[1];
$flag=$result->fields[2];
$id=$result->fields[3];
if($flag){
$isread="是";
}else{
$isread="否";
}
echo<<<EOD
<table width=100% border=0 cellspacing=0 cellpadding=2 align=center>
<tr align=center>
<td width="67"><acronym title='给用户发一个短信息'><a href='messager.php?job=write&target=$author'>$author</a></acronym></td>
<td><a href='messager.php?job=read&msg=$id'>$title</a></td>
<td width="26">$isread</td>
</tr></table>
EOD;
sline();
$result->MoveNext();
} }else{
echo "<br>$articleusername 您没有任何短消息"; exit;
}
$result->close();
}
if ($job=="write") {
if (empty($step)){
print_form();
}elseif($step==2){
if (empty($content) || empty($title) || empty($ruser)) {
echo "对不起,发生资料错误,请 <a href='javascript:history.back(1);'>返回检查</a>";
exit;
}
if (strlen($content)>200) {
echo "对不起,短消息内容不能超过200个字符,请 <a href='javascript:history.back(1);'>返回检查</a>";
exit;
}
$content.="\n<br><br>[来源:文章系统]";
$stime=date("Y-m-d H:i:s");
$title=textconvert($title);
$content=textconvert($content);
$sql="INSERT INTO message(sender,incept,title,content,flag,sendtime)VALUES('$articleusername','$ruser','$title','$content',0,'$stime')";
$addinfo=$userdb->Execute($sql);
if (!$addinfo) {
print '添加错误: '.$db->ErrorMsg().'<BR>';
}else{
echo "<br>已经完成,<a href='messager.php?job=receivebox'>点这里返回收件箱</a>";
exit;
}
}
}
if ($job=="clear") {
$sql="DELETE FROM message WHERE incept='$articleusername' and flag<>0";
$addinfo=$userdb->Execute($sql); if (!$addinfo) {
print '删除错误: '.$db->ErrorMsg().'<BR>';
}else{
echo "<br>您的所有短信息已被成功清空";
exit;
}
}function print_form() {
global $target;
echo<<<EOD
<table width=205 border=0 cellspacing=0 cellpadding=0>
<tr bgcolor=F3F3F3>
<td> 请填写信息</td>
</tr><form action=messager.php method=POST>
<tr bgcolor=#FFFFFF>
<td>
接收用户:
<input value='$target' style="background-color:#ffffff; color:#9999FF; border: 1 double #B4B4B4" onMouseOver = "this.style.backgroundColor = '#E5F0FF'" onMouseOut ="this.style.backgroundColor =''" type=text size=12 name="ruser"><br>
留言题目:
<input style="background-color:#ffffff; color:#9999FF; border: 1 double #B4B4B4" onMouseOver = "this.style.backgroundColor = '#E5F0FF'" onMouseOut ="this.style.backgroundColor =''" type=text size=38 name="title">
<br>
<textarea style="background-color:#ffffff; border: 1 double #B4B4B4" onMouseOver = "this.style.backgroundColor = '#f3f3f3'" onMouseOut = "this.style.backgroundColor = ''" name="content" cols=40 rows=3></textarea>
<br>
</td>
</tr>
<tr bgcolor=FFFFFF>
<td><input style="color: #000000; background-color: #f3f3f3; border-style: solid; border-width: 1" onMouseOver ="this.style.backgroundColor='#FFC864'" onMouseOut ="this.style.backgroundColor='#f3f3f3'" type=submit value="提 交">
<input type=hidden name=job value=write>
<input type=hidden name=step value=2>
</td>
</tr></form>
</table>
EOD;
}
给出一些代码,自己看看吧
不全,有些需要的没有给出,但是你说的已有了,你看看吧
有未读,有已读等状态,就可以了
不过如果你收到多个短信,就会在同时打开这些短信,好象CSDN也是这样做的