伊莉部落格、伊莉交友、伊莉聊天、伊莉相簿
有PHP高手嗎 最近在搞PHP聊天
最近在寫聊天室 遇到兩個問題
第一個問題 怎麼寫 都無法寫出 如果沒有輸入訊息 訊息還是會被送出
第二個問題 只要按下 [重整] 之前輸入的訊息 並不會不見 而是會重複po上去
第三個 如果我要讓輸出的 資訊 是有表格的 我應該在哪個程式段 改呢
我架設的地點 http://210.208.58.59/gamebk2
程式碼 chat.php (我有省略一些不重要的了)
<?
if(!$chatname) {
print_form();
exit;
};
foreach ($online_array as $user_on) {
$fields = explode(",",$user_on);
if( $fields[0] < $lasttenmin ){
break;
}
if( $fields[1] == "$chatname\n" ){
break;
}
$updated .= $user_on;
}
$updated .= "$rightnow\,$chatname\n";
$online = stripslashes($updated);
$chatname = htmlspecialchars($chatname);
$message = htmlspecialchars($message);
$new_message = "<font color=00008B><b>$time</b><font color=FF0000 ><b>$chatname</b> $from_ip $dod $level $bob :<font color=\"$myfont\"> $message<p>\n </font>";
$header = "<html><head>".
"<meta http-equiv=\"pragma\" content=\"no-cache\">".
"<meta name=\"robots\" content=\"noindex\"></head>".
"<body bgcolor=\"#ffffff\" text=\"#000000\"><p>".
"<embed src=\"alert.wma\" width=2 height=0 autostart=true loop=false> <noembed> <bgsound src=\"alert.wma\" loop=none> </noembed>\n";
$footer = "</body>"."</html>";
$open_file = fopen("messages.htm", "w");
fputs($open_file, $header);
fputs($open_file, stripslashes($new_message));
fputs($open_file, $old_messages);
fputs($open_file, $footer);
fclose($open_file);
$open_file = fopen("history.htm", "w");
fputs($open_file, $header);
fputs($open_file, stripslashes($new_message));
fputs($open_file, $old_history);
fputs($open_file, $footer);
fclose($open_file);
print_form_nameset();
function print_form()
{
global $chatname;
global $PHP_SELF;
echo <<<FORM1
<link href="css.css" rel="stylesheet" type="text/css" />
</head>
<body bgcolor="#cccccc" text="#000000">
<table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td >
<form name="chat" method="post" action="$PHP_SELF" >
[ 瀏覽完整內容請先註冊或登入會員。]
|