Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <div id="chat"></div><br />
- <form action="#" method="post">
- <input type="hidden" id="nome" value="<?=$usuario?>" size="6">
- <input type="text" id="mensagem" width="80%" >
- <button type="button" id="enviar" title="enviar" >Enter</button>
- </form>
- <?php
- $nome = $_POST['nome'];
- $mensagem = $_POST['mensagem'];
- $linha = $nome.' - '.$mensagem.'<br>';
- $arquivo = file('chatlog.htm');
- array_unshift($arquivo, $linha);
- file_put_contents('chatlog.htm', $arquivo);
- ?>
- $(function() {
- conversar();
- $('#enviar').click(function() {
- var nome = $('#nome').val();
- var mensagem = $('#mensagem').val();
- $.post('chat.php', {'nome':nome, 'mensagem': mensagem }, function() {
- conversar;
- $('#mensagem').val('');
- });
- });
- function conversar() {
- $('#chat').load('chatlog.htm');
- $('#mensagem').focus();
- }
- setInterval(conversar, 3000);
- });
- #chat {
- width: 300px;
- height: 400px;
- border: black 1px solid;
- background-color: #000000;
- overflow-x: hidden;
- overflow-y: scroll;
- padding: 5px;
- margin-left: 10px;
- }
- fieldset {
- width: 330px;
- background-color: #e6e2af;
- border: black 1px solid;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement