M
M
MartStap2014-06-02 17:17:20
PHP
MartStap, 2014-06-02 17:17:20

How to add "read/unread" to messages?

How to record that a person has read a message?

<?php 

if(isset($_POST['submit'])){
  $ad = $_POST['po'];
  
  $rand = $userdata['users_id'].$ad;
  $u = "INSERT INTO `user40727_chat`.`stena` (`ot`,`po`,`tex`,`rand`,`time`) VALUES ('" . $userdata['users_id'] . "','$_POST[po]','$_POST[stena]','".$rand."', '".time('dmYhis')."')";
  mysql_query($u) or die(mysql_error($link));
  header('Location: mass.php?id='.$ad);
  
  }
  ?>

Answer the question

In order to leave comments, you need to log in

2 answer(s)
P
Pavel Solovyov, 2014-06-02
@pavel_salauyou

add a new boolean field to the table and name it prochitano and please read about pdo and php in general

A
Alexey Kuleshov, 2014-06-02
@GingerbreadMSK

First: NEVER use what you wrote in the example about injecting variables from POST into a SQL query string.
Secondly, as already stated, use a column (preferably TINYINT 0/1) to store the boolean value read/unread (1/0).

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question