Здравствуйте пацаны, решил сделать себе скрипт комментариев на сайт, но возникла проблема при добавлении комментарии открывается пустая страница, и приходит нажимать назад и обновлять страницу после этого появляется комментарий, и ещё когда я обновляю пустую страницу комментарии повторяются
SupeR-InG
<?php
//This part of the code writes the comment to a text file
$name = $comment = «»; // Creates the variables and makes them blank
if ($_SERVER[«REQUEST_METHOD»] == «POST») { // If the post button is pressed
function format($data) {
$data = trim($data); // Trims the data
$data = stripslashes($data); // Un-quotes the data (Do not change this)
$data = htmlspecialchars($data); // Protects against characters that would break the code
return $data; // Gives back the data
}
$comment = format($_POST[«comment»]); // Formats the comment
$name = format($_POST[«name»]); // Formats the name
if($comment != «») { // If the user has typed something into the comment box
if($name == «») { // If there is no name
$name = «Anonymous»; // Set the name to Anonymous
}
// These just turn ASCII emoticons in to unicode ones
$date = date(«d.m.Y»); // Generate the current date
$file = file_get_contents(«chat.txt»); // Defines the file in wich comments are stored
$datarray = unserialize($file); // Turns the files contents into an array
$full = array // Combines all the data into an array
($date, $name, $comment);
$datarray[] = $full; // Adds this array to a bigger array of all the comments
$newfile = serialize($datarray); // Turns the array into a string we can store
file_put_contents(«chat.txt», $newfile); // Stores the string into the file
function Redirect($url, $permanent = false) // Refreshes the page so the comment appears(and removes the old data so you dont post the same comment again on refresh)
SupeR-InG
Здравствуйте пацаны, решил сделать себе скрипт комментариев на сайт, но возникла проблема при добавлении комментарии открывается пустая страница, и приходит нажимать назад и обновлять страницу после этого появляется комментарий, и ещё когда я обновляю пустую страницу комментарии повторяются
SupeR-InG
SupeR-InG
miketomlin
Вот код в чем ошибка?
Не считая того, что вы комменты в текстовом файле храните? 😀
Что за скобка в адресе редиректа?
P.S. Dr.Web блокирует ваш сайт 😉