RashGamer
Newbie | Редактировать | Профиль | Сообщение | Цитировать | Сообщить модератору Мне нужна страничка с формой, чтоб она сохраняла вводимые данные в текстовый файл. Мне помогли с этим дали страничку, я ее разместил на бесплатном хостинге с поддержкой 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 Помогите плиз разобраться! |