Home Backend Development PHP Tutorial 聊天室技术(五) -- 指挥中心_PHP

聊天室技术(五) -- 指挥中心_PHP

Jun 01, 2016 pm 12:34 PM
gt lt name center technology command chatroom

这里是聊天室的指挥中心,所有的指令都要在这里发出

 

1下面是基本的发送表单代码

<form name=inputform action='messagesend.php' target='bl' onsubmit='return(checksay());' method=POST>

<?
//下面的2个参数用于验证信息的正确性
print("<input type='hidden' name='name' value='$name'>n");
print("<input type='hidden' name='pass' value='$pass'>n");
?>

//聊天对象,注意加上 readonly 属性
<input type="text" name="talkto" size="10" maxlength="20" readonly value="所有人">

//上次聊天的发送内容
<input type='hidden' name='message' value=''>

//发送的表单文本框
<input type="text" name="msg" maxlength="120" size="34">

<input type="submit" name="Submit" value="发送">

</form>

2 检查发送内容的js

var dx ='';
function checksay( )
{

//不允许发送空的发言
if(document.inputform.msg.value=='')
{
document.inputform.msg.focus();
return false;
}

//不允许重复发言,内容相同,对象相同
if ((document.inputform.msg.value==document.inputform.message.value)&&(document.inputform.talkto.value==dx))
{
alert('发言不能重复');
document.inputform.msg.focus();
return false;
}

//两次发言内容的间隔不能小于1秒,或者发言字数大于间隔*3
t2=(new Date()).getTime()/1000;
if(((t2-t1)<1)||((t2-t1)*3<document.inputform.msg.value.length))
{
document.inputform.msg.focus();
return false;
}

//更新时间
t1=t2;

document.inputform.showsign.value=1;

//保存上次发言内容
document.inputform.message.value =document.inputform.msg.value;

//清空发言内容
document.inputform.msg.value ='';

//保存发言对象
dx=document.inputform.talkto.value;

//定位焦点
document.inputform.msg.focus();

//返回
return(true);
}

3调用信息发送程序,发布聊天者已经进入的信息
<script>
parent.bl.document.open();
parent.bl.document.write("<meta http-equiv='refresh' content='0;url=messagesend.php?name=<? print($name); ?>&&action=enter&&pass=<? print($pass); ?>'>")
parent.bl.document.close();
</script>

发言由messagesend.php处理完成,注意输出对象为bl,也就是处理发言的框架名称,这样保证发言框架的页面内容的完整

原作者:howtodo
来源:php2000.com

Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn

Hot Article Tags

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

What are the differences between Huawei GT3 Pro and GT4? What are the differences between Huawei GT3 Pro and GT4? Dec 29, 2023 pm 02:27 PM

What are the differences between Huawei GT3 Pro and GT4?

This article is enough for you to read about autonomous driving and trajectory prediction! This article is enough for you to read about autonomous driving and trajectory prediction! Feb 28, 2024 pm 07:20 PM

This article is enough for you to read about autonomous driving and trajectory prediction!

The Stable Diffusion 3 paper is finally released, and the architectural details are revealed. Will it help to reproduce Sora? The Stable Diffusion 3 paper is finally released, and the architectural details are revealed. Will it help to reproduce Sora? Mar 06, 2024 pm 05:34 PM

The Stable Diffusion 3 paper is finally released, and the architectural details are revealed. Will it help to reproduce Sora?

Have you really mastered coordinate system conversion? Multi-sensor issues that are inseparable from autonomous driving Have you really mastered coordinate system conversion? Multi-sensor issues that are inseparable from autonomous driving Oct 12, 2023 am 11:21 AM

Have you really mastered coordinate system conversion? Multi-sensor issues that are inseparable from autonomous driving

DualBEV: significantly surpassing BEVFormer and BEVDet4D, open the book! DualBEV: significantly surpassing BEVFormer and BEVDet4D, open the book! Mar 21, 2024 pm 05:21 PM

DualBEV: significantly surpassing BEVFormer and BEVDet4D, open the book!

The first multi-view autonomous driving scene video generation world model | DrivingDiffusion: New ideas for BEV data and simulation The first multi-view autonomous driving scene video generation world model | DrivingDiffusion: New ideas for BEV data and simulation Oct 23, 2023 am 11:13 AM

The first multi-view autonomous driving scene video generation world model | DrivingDiffusion: New ideas for BEV data and simulation

GSLAM | A general SLAM architecture and benchmark GSLAM | A general SLAM architecture and benchmark Oct 20, 2023 am 11:37 AM

GSLAM | A general SLAM architecture and benchmark

'Minecraft' turns into an AI town, and NPC residents role-play like real people 'Minecraft' turns into an AI town, and NPC residents role-play like real people Jan 02, 2024 pm 06:25 PM

'Minecraft' turns into an AI town, and NPC residents role-play like real people

See all articles