|
马上注册,结交更多好友,享用更多功能,让你轻松玩转社区。
您需要 登录 才可以下载或查看,没有帐号?立即注册
x
我的文章不会对您的学习起到实质性的作用,您能否成功,还得靠自己的,坚持,坚持,再坚持,就是步入成功的不二法门。法式|精髓 文章来历:php世纪网
5 聊天信息的发送、浏览和答复法式 - shortalk.php
<?
require("require.php"); // 判别用户是不是正当在线的公用法式
?>
<html>
<head>
<title>短信息</title>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<style type="text/CSS">
td {font-size:9pt}
</style>
<script language="Javascript">
<!--
function docheck() {
if (document.sendmsg.replymessage.value=="") {
alert("短少内容:需求输出您的留言内容");
document.sendmsg.replymessage.focus();
return(false);
}
return (true);
}
function MM_openBrWindow(theURL,winName,features) { //v2.0
window.open(theURL,winName,features);
}
//-->
</script>
</head>
<body bgcolor="#DDDDFF"leftmargin="0" topmargin="0" background="phpchat_images/cloudtile.jpg">
<?
if($action == "view")
{
$tmp = mysql_fetch_array(mysql_query("select sender,body,date from forumtalk where id=$talknumber and receiver='$name'"));
$msg = $tmp['body'];
$message = ereg_replace("
","\r\n",$msg);
mysql_query("update forumtalk set readsign=1 where id=$talknumber");
$sendernickname = mysql_fetch_row(mysql_query("select nickname from userinfo where name='".$tmp['sender']."'"));
?>
<table width="300" border="0" cellspacing="0" cellpadding="0" height="200" bgcolor="f0f0f0">
<tr>
<td colspan="2" height="20" bgcolor="99cc99" align="center">检查短信息</td>
</tr>
<tr>
<td colspan="2" height="20"><?echo date("m月d日 h:i",$tmp['date'])." ".$sendernickname[0]?> 给你[<?echo $name?>]留言:</td>
</tr>
<form name=viewtalk action=shortalk.php method=post>
<input type=hidden name=talkto value=<?echo $tmp['sender']?>>
<input type=hidden name=action value=send>
<input type=hidden name=talknumber value=<?print($talknumber)?>>
<tr align="center">
<td colspan="2" height="146" valign="top">
<textarea name="textfield" cols="40" rows="11" readonly><?print($message)?></textarea>
</td>
</tr>
<tr>
<td colspan="2" align="center">
<input type="submit" name="toreply" value="答复留言 Enter">
<a href="#" onClick="MM_openBrWindow('memberviewtalk.php?talkto=<?echo $tmp['sender']?>','viewtalk','scrollbars=yes')">聊天记载</a> </td>
</tr>
</form>
</table>
<script language="Javascript">
document.viewtalk.toreply.focus();
</script>
<?
}
else if ($action == "sendbegin")
{
$replymessage = ereg_replace("\r\n","
",$replymessage);
$replymessage = ereg_replace(">",">",$replymessage);
$replymessage = ereg_replace("<","<",$replymessage);
$replymessage = substr($replymessage,0,2000);
mysql_query("insert into forumtalk (sender,receiver,body,date) values ('$name','$talkto','$replymessage',".date("U").")");
print("<script language='javascript'>window.close()</script>");
}
else
{
?>
<table width="300" border="0" cellspacing="0" cellpadding="0" height="200" bgcolor="f0f0f0">
<form name=sendmsg action=shortalk.php method=post OnSubmit=return(docheck());>
<input type=hidden name=action value=sendbegin>
<tr align="center">
<td colspan="2" height="20" bgcolor="99cc99">发送短信息</td>
</tr>
<tr align="center">
<td colspan="2" height="20">讲话对象:
<select name="talkto">
<?
$result = mysql_query("select name,nickname from userinfo where onlinestatus=1");
while($msg=mysql_fetch_array($result))
{
if($msg['name']==$talkto)
echo "<option value='".$msg['name']."' selected>".$msg['nickname']."</option>\n";
else
echo "<option value='".$msg['name']."'>".$msg['nickname']."</option>\n";
}
?>
</select>
请短于500字符 </td>
</tr>
<tr align="center">
<td colspan="2" height="146" valign="top">
<textarea name="replymessage" cols="40" rows="9"></textarea>
</td>
</tr>
<tr align="center">
<td colspan="4">
<?
if($talknumber != "")
{
print("<input type=button name=review value='检查前一留言 Alt+P' accesskey='p' )">聊天记载</a></td>
</tr>
</form>
</table>
<script language="Javascript">
document.sendmsg.replymessage.focus();
</script>
<?
}
?>
</body>
</html>
第1步环境配置好了,你算了进了1小步了,那么第2步呢 就是调出第1个程序 一般都是用hello world,视频教程里面我都做了,hello world |
|