This is the command center of the chat room. all commands must be sent here. 1. below is the basic sending form code lt; formnameinputformactionmessagesend. phptargetblonsubmitreturn (checksay (); methodPOSTgt; lt ;? The following two parameters are used to verify the correctness of the information. print (lt; inputtypehidden: the command center of the chat room. all the commands must be issued here.
1. The following is the basic sending form code.
<Form name = inputform action = 'messagesend. php' target = 'bl' onsubmit = 'return (checksay (); 'method = POST>
<?
// The following two parameters are used to verify the correctness of the information.
Print ("<input type = 'siden' name = 'name' value = '$ name'> n ");
Print ("<input type = 'ddn' name = 'pass' value = '$ pass'> n ");
?>
// Chat object. add the readonly attribute.
<Input type = "text" name = "talkto" size = "10" maxlength = "20" readonly value = "all">
// Content sent from the last chat
<Input type = 'siden' name = 'message' value = ''>
// Send the form text box
<Input type = "text" name = "msg" maxlength = "120" size = "34">
<Input type = "submit" name = "Submit" value = "Send">
</Form>
2. check the js of the sent content
Var dx = '';
Function checksay ()
{
// Do not send blank speeches
If (document. inputform. msg. value = '')
{
Document. inputform. msg. focus ();
Return false;
}
// Repeated speeches are not allowed. the content is the same and the objects are the same.
If (document. inputform. msg. value = document. inputform. message. value) & (document. inputform. talkto. value = dx ))
{
Alert ('statement cannot be repeated ');
Document. inputform. msg. focus ();
Return false;
}
// The interval between two speeches cannot be less than 1 second, or the interval between the two speeches * 3
T2 = (new Date (). getTime ()/1000;
If (T2-T1) <1) | (T2-T1) * 3 <document. inputform. msg. value. length ))
{
Document. inputform. msg. focus ();
Return false;
}
// Update time
T1 = t2;
Document. inputform. showsign. value = 1;
// Save the content of the previous speech
Document. inputform. message. value = document. inputform. msg. value;
// Clear the speech content
Document. inputform. msg. value = '';
// Save the speaker
Dx = document. inputform. talkto. value;
// Locate the focus
Document. inputform. msg. focus ();
// Return
Return (true );
}
3. call the information Sender program to publish information that the chatbot has entered.
<Script>
Parent.bl.doc ument. open ();
Parent.bl.doc ument. write ("<meta http-equiv = 'refresh' content = '0; url = messagesend. php? Name = <? Print ($ name);?> & Action = enter & pass = <? Print ($ pass);?> '> ")
Parent.bl.doc ument. close ();
</Script>
The speech is processed by messagesend. php. Note that the output object is bl, that is, the name of the framework for processing the speech. This ensures that the content on the page of the speech framework is complete.
Original Author: howtodo
Source: php2000.com