|
|
|
| Здраствуйте!
Мне нужна страничка с формой, чтоб она сохраняла вводимые данные в текстовый файл.
Мне помогли с этим дали страничку, я ее разместил на бесплатном хостинге с поддержкой php, но почему то страничка отказываеться работать. Вот эта страничка.
Помогите плиз разобраться в чем проблема вот код странички:
<?php
$login = isset($_POST['login'])?$_POST['login']:null;
$message = isset($_POST['message'])?$_POST['message']:null;
if(isset($_POST['ok']))
{
if(!$login)
{
echo "Текстовое поле не заполнено.";
}
elseif(!$message)
{
echo "Текстовая область не заполнена.";
}
elseif(file_exists("text.txt") && file_get_contents("text.txt"))
{
$message = $login."\r\n".$message."\r\n".file_get_contents("text.txt");
$fp = fopen("text.txt","w");
flock($fp, LOCK_EX);
fseek($fp,0,SEEK_END);
fputs($fp,$message);
flock($fp, LOCK_UN);
fclose($fp);
chmod("text.txt",0600);
header("location: ".$_SERVER['PHP_SELF']."?a=".rand(100,1));
}
else
{
$fp = fopen("text.txt","w");
flock($fp, LOCK_EX);
fseek($fp,0,SEEK_END);
fputs($fp,$login."\r\n".$message."\r\n");
flock($fp, LOCK_UN);
fclose($fp);
chmod("text.txt",0600);
header("location: ".$_SERVER['PHP_SELF']."?a=".rand(100,1));
}
}
else
{
$default = "Напишите что нибудь.<br>";
}
if(file_exists("text.txt"))
$text = nl2br(htmlspecialchars(file_get_contents("text.txt")));
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>Форма</title>
<meta content="text/html; charset=windows-1251" /></head>
<body>
<form action="?" method="post">
Логин:<br />
<input name="login" type="text" value="<?php echo htmlspecialchars($login) ?>"/><br />
Сообщение:<br />
<textarea name="message" cols="40" rows="10"><?php echo htmlspecialchars($message) ?></textarea><br />
<input name="ok" type="submit" />
</form>
<?php
echo $default, $text;
?>
</body>
</html>
|
Вот что пишеться при заполнении и отправке:
Warning: fopen(text.txt) [function.fopen]: failed to open stream: Permission denied in /home/far/a/p/c/apcent/public_html/770.php on line 30
Warning: flock(): supplied argument is not a valid stream resource in /home/far/a/p/c/apcent/public_html/770.php on line 31
Warning: fseek(): supplied argument is not a valid stream resource in /home/far/a/p/c/apcent/public_html/770.php on line 32
Warning: fputs(): supplied argument is not a valid stream resource in /home/far/a/p/c/apcent/public_html/770.php on line 33
Warning: flock(): supplied argument is not a valid stream resource in /home/far/a/p/c/apcent/public_html/770.php on line 34
Warning: fclose(): supplied argument is not a valid stream resource in /home/far/a/p/c/apcent/public_html/770.php on line 35
Warning: chmod() [function.chmod]: Unable to access text.txt in /home/far/a/p/c/apcent/public_html/770.php on line 36
Warning: chmod() [function.chmod]: No such file or directory in /home/far/a/p/c/apcent/public_html/770.php on line 36
Warning: Cannot modify header information - headers already sent by (output started at /home/far/a/p/c/apcent/public_html/770.php:30) in /home/far/a/p/c/apcent/public_html/770.php on line 37
|
Помогите плиз разобраться | |
|
|
|
|
|
|
|
для: RashGamer
(01.03.2009 в 12:55)
| | у php-скрипта не хватает прав создать файл text.txt в текущем каталоге.
Остальные ошибки - следствие первой. | |
|
|
|
|
|
|
|
для: Trianon
(01.03.2009 в 14:01)
| | поставил 777 на дерикторию и на сам php файл но всеравно косяк
Warning: fopen(text.txt) [function.fopen]: failed to open stream: Permission denied in /home/far/a/p/c/apcent/public_html/770.php on line 30
Warning: flock(): supplied argument is not a valid stream resource in /home/far/a/p/c/apcent/public_html/770.php on line 31
Warning: fseek(): supplied argument is not a valid stream resource in /home/far/a/p/c/apcent/public_html/770.php on line 32
Warning: fputs(): supplied argument is not a valid stream resource in /home/far/a/p/c/apcent/public_html/770.php on line 33
Warning: flock(): supplied argument is not a valid stream resource in /home/far/a/p/c/apcent/public_html/770.php on line 34
Warning: fclose(): supplied argument is not a valid stream resource in /home/far/a/p/c/apcent/public_html/770.php on line 35
Warning: chmod() [function.chmod]: Operation not permitted in /home/far/a/p/c/apcent/public_html/770.php on line 36
Warning: Cannot modify header information - headers already sent by (output started at /home/far/a/p/c/apcent/public_html/770.php:30) in /home/far/a/p/c/apcent/public_html/770.php on line 37
|
| |
|
|
|
|
|
|
|
для: RashGamer
(01.03.2009 в 16:07)
| | может скрипту надо другие права? не 777 | |
|
|
|
|
|
|
|
для: RashGamer
(01.03.2009 в 16:07)
| | при чем тут права скрипт-файла? Вы ж не в него пишете? | |
|
|
|
|
|
|
|
для: Trianon
(01.03.2009 в 16:21)
| | теперь записываеться в файл но еще ошибку пишет вот такую:
Warning: chmod() [function.chmod]: Operation not permitted in /home/far/a/p/c/apcent/public_html/770.php on line 25
Warning: Cannot modify header information - headers already sent by (output started at /home/far/a/p/c/apcent/public_html/770.php:25) in /home/far/a/p/c/apcent/public_html/770.php on line 26
|
| |
|
|
|
|
|
|
|
для: RashGamer
(01.03.2009 в 17:00)
| | а зачем Вы меняете права на файл? Оно Вам не дозволено. | |
|
|
|
|
|
|
|
для: RashGamer
(01.03.2009 в 17:00)
| | Это же для эксперемента чмод меняли, Я исправил, файл там же. | |
|
|
|