0
我在我的代碼中做錯了什麼?讓我解釋一下,我正在爲我的學校編寫一個聊天應用程序,並且讓用戶自由地在.txt數據庫之間切換,我做了一個簡單的表單和If ... Then語句來切換$ file ='chatmsg.txt'到$ file ='indexmsg.txt'。我認爲我有正確的,但顯然不是。我究竟做錯了什麼?感謝您的輸入。文件切換在聊天應用程序代碼更正
if (isset($HTTP_GET_VARS['f1']))
{
$f2 = file($file) ;
echo("<html><head><title></title><meta http-equiv='Content-Type' content='text/html; charset=utf-8'></head>") ;
echo("<body text=#0000cc><meta http-equiv='refresh' content='{$refresh}; url={$HTTP_SERVER_VARS['REQUEST_URI']}'>") ;
echo("<font color=#e22200>Online Users: ") ;
foreach($users as $u) echo "<font color=#ee0099>".$u."</font> - " ;
echo "</font><hr>" ;
for($i=0; isset($f2[$i]) && $i<$max; $i++) {
$e=explode("||", $f2[$i]) ;
if ($e[2]!="\r\n") echo "<font color=green>{$e[0]}</font> <font color=red>:</font> {$e[2]}<br>\r\n" ;
}
die("</body></html>") ;
}
else
{
$html = <<<EOA
<html><head><title>KeyChat</title><meta http-equiv='Content-Type' content='text/html; charset=utf-8'>
<script><!--
function msg(){ document.m.msg.focus(); } // --></script>
</head>
<body align='center' onLoad='msg()'> <center>
<iframe src='?f1=1' width='95%' height='70%'></iframe><br>
<table width='95%'><tr><td align='center' width='100%'>
<form action='' method='post' name='m'>
Message : <input name='msg' size=60> <input type='submit' name='send' value='Send'>
<br />
</form>
</td></tr></table>
<h3>Welcome to KeyChat</h3>
<p><big>NOTICE: Please chat at home, not at school. If you chat at school, do realize that you hold all responsibility for not taking seriously this notice.</p></big>
<form name="name" action="test.php?name=Aaron" method="post">
<input type="radio" name="name" value="Aaron" /> Aaron<br />
<input type="radio" name="name" value="Benjamin" /> Benjamin<br />
<input type="submit" value="Submit">
EOA;
die($html);
}
if(empty($_REQUEST["name"]))
echo "No POST variables" ;
else
$file = 'indexmsg.txt' ;
嗨mhretchin - 代碼審查是審查[工作代碼](http://codereview.stackexchange.com/faq)。我正在將它遷移到Stack Overflow,它在主題上。 – 2011-04-15 14:29:20