I am trying to generate a simple .txt file with php and it does not allow it. This is my form:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Guardar archivos</title>
</head>
<body>
<form action="guardar.php" method="POST" name="frm">
<input type="text" name="nombre"><br><br>
<textarea name="comentario"></textarea><br><br>
<input type="submit" value="Guardar datos">
</form>
</body>
</html>
and this is my file generator:
<?php
$fi = fopen("archivo.txt", "a") or die ("Problemas al crear archivo");
$nom = $_REQUEST['nombre'];
$com = $_REQUEST['comentario'];
fwrite($fi, "Datos: ");
fwrite($fi, "\n");
fwrite($fi,$nom);
fwrite($fi, "\n");
fwrite($fi,$com);
fwrite($fi, "\n");
fwrite($fi, "----------------------------------------------------- \n \n");
fclose($fi);
echo "Archivo guardado";
?>
What happens is that it always generates the message that goes in the case of the or die.
Thank you very much for the help