2
I’m finding a problem in the following code:
<?php
$id = $_POST['id'];
$titulo = $_POST['titulo'];
$imagem = $_POST['imagem'];
$coment = $_POST['coment'];
$finalcoment = '<div id="triplox"><a name="index-' . $id . '"></a><br><div id="idnoticias"><center><a href="HTML/Noticias/index-' . $id . '.php"><u>' . $titulo . '</u></a></center></div><br><br><center><img width="90%" height="90%" src="Imagens/' . $imagem . '.jpg"></center><p>' . $coment . '</p><br><center>Postado : ' . date('d/m/y') . '</center><br><br></div>' ;
// abre o arquivo colocando o ponteiro de escrita no final
$arquivo = fopen('../../../HTML/noticias.php','a+');
if ($arquivo) {
    // move o ponteiro para o inicio do arquivo
    rewind($arquivo);
    if (!fwrite($arquivo, $finalcoment)) die('Não foi possível atualizar o arquivo.');
    echo 'Arquivo atualizado com sucesso';
    fclose($arquivo);
}
?>
<meta http-equiv="refresh" content="1; ../noticias.php">
In theory he should take the values of strings, mount it inside the code to write at the beginning of the other file .php. He is writing the code all right but not at the beginning of the page, he is writing in continuation to the last typed code. Here comes the big question, what I did wrong in the code?
It worked right vlw
– Fratura Exposta