vendredi 29 janvier 2021

i get "Cannot modify header information" warning when i try to refresh my page with php code [duplicate]

im trying to make messaging thing and how it works? it stores user input to txt file but after it, it refreshes the page to display latest input but i can make it refresh it because i get "cannot modify header information" warning :/ and all that i tried didn't work, i test every answer i get.

<?php
$ip = (isset($_SERVER["HTTP_CF_CONNECTING_IP"])?$_SERVER["HTTP_CF_CONNECTING_IP"]:$_SERVER['REMOTE_ADDR']); 
$user_agent = $_SERVER['HTTP_USER_AGENT'];

if(isset($_POST['send']))
{
$message=$_POST['message'];
$fp = fopen('messages.txt', 'a',1);
fwrite($fp, "Unknown: $message".PHP_EOL);
fclose($fp);

header("Refresh:0");
}

?> what did i do wrong? :( it works if i manually refresh page after sending message :/

[image of error][1] [1]: https://ift.tt/3t87ofy




Aucun commentaire:

Enregistrer un commentaire