-1
I’m creating a chat system to implement in a project, and I’m having trouble recording and rescuing within a file .txt, when I manually write to the file it opens, I’m just not able to write to the system, and in the html console no errors appear
follows the codes created.
Index.js
function tempo(){
setInterval(ler,3000);
};
function ler(){
$("#conversa").load("ler.php");
};
function escrever(){
var mensagens = "textarea";
var usuario = "imput:text";
$.ajax({ type:"POST",
url:"escrever.php",
data:{"mensagens":mensagens, "usuario":usuario},
success:function(){
ler();
}});}
write.php
<?php
$file = file_get_contents("chat.txt");
$mensagens = "<b>" $_POST['usuario']. "</b> diz: ".$_POST['mensagens']."<br>";
$file = file_put_contents("chat.txt", $file; $mensagens);
?>
read php.
<?php
$file = file_get_contents("chat.txt");
print $file;
?>
This var usuario = "imput:text"; misspelled, already tested?
– Leticia Rosa
my input in index is like this: <input type="text" id="text" class="form-control" placeholder="User"/> ai put like this : var usuario = "text"; that would be it ?
– Fabrizzio
No, you wrote input with m... Fix this and play on the console or an Alert to see if it’s picking up the text there...
– Leticia Rosa
even so it is giving error, after which I answered I realized the error
– Fabrizzio