Excell

Advanced Member | Редактировать | Профиль | Сообщение | Цитировать | Сообщить модератору 2all есть примитивное подобие гестбука. Выглядит оно так: Код: <html><head><title>Ecaea?aiea o?eia ec oaeea</title></head><body> <?php function WriteToFile ($URL, $Description, $NickName) { $TheFile = "data_guest.txt"; $Open = fopen ($TheFile, "a"); if ($Open) { fwrite ($Open, "$URL\t$Description\t$NickName\n"); fclose ($Open); $Worked = TRUE; } else { $Worked = FALSE; } return $Worked; } function ReadFromFile () { $TheFile = "data_guest.txt"; $Open = fopen ($TheFile, "r"); if ($Open) { print ("URLs currently listed in the data file:<p>\n"); $Data = file ($TheFile); for ($n=0; $n < count($Data); $n++) { $GetLine=explode("\t", $Data[$n]); print ("<b>$GetLine[0]</b><br>\n$GetLine[1]<br>\n$GetLine[2]<p>\n"); } fclose ($Open); print ("<hr><p>\n"); } else { print ("Unable to read from data_guest.txt!<br>\n"); } } function CreateForm () { print ("Add a URL to the data file:\n"); print ("<form action=\"guest.php\" method=post>\n"); print ("NickName <input type=text name=\"Array[NickName]\" size=20><br>\n"); print ("URL <input type=text name=\"Array[URL]\" size=60><br>\n"); print ("Description <textarea name=\"Array[Description]\" rows=5 cols=40></textarea><br>\n"); print ("<input type=hidden name=\"BeenSubmitted\" value=\"true\">\n"); print ("<input type=submit name=\"submit\" value\"Submit!\"></form>\n"); } function HandleForm () { global $Array; $Pattern= "(http://)?([^[:space:]]+)([[:alnum:]\.,-_?/&=])"; if (eregi($Pattern, $Array["URL"])) { $Replace= "<a href=\'http://\\2\\3\" target=\"_new\">\\2\\3</a>"; $Array["URL"]=eregi_replace($Pattern, $Replace, $Array["URL"]); $CallFunction = WriteToFile ( $Array[NickName], $Array["URL"], $Array[Description]); if ($CallFunction) { print ("Ur submission-$Array[URL]-has been received!<p><hr><p><br>\n"); } else { print ("Ur submition was not processeddue to a system error!<br>\n"); } } else { print ("Please enter a valid Web address!<br>\n"); } } if ($BeenSubmitted) { HandleForm (); } ReadFromFile (); CreateForm (); ?></body></html> | и почему-то, если обновляешь (F5) скрипт, то выполняется последнее сделанное действие (напр. ввод данных опять записывается в файлике, если ничего не вводить в форме). Как сделать так, чтобы не происходило никаких действий после обновления страницы?
---------- Построю лабиринт, в котором смогу затеряться с тем, кто захочет меня найти... Кто это сказал и о чем? |
|