I am asking for help on two things. So basically I have made a messaging website for my friends and I but I have came across two things:
- My messaging website tells you what time the message was sent, but at the minute each time you hit refresh the time changes to the current time 
- At the minute you have to refresh to view a new message so I was wondering how I would make this automatic, I've heard of Ajax but I didn't understand how it works so you would need to explain it to me 
Here's the code:
<?php
  $username = "";
  $password = "";
  $server = "";
  $database = "";
  mysql_connect($server, $username, $password);
  @mysql_select_db($database) or die("Unable to select database");
?>
<!DOCTYPE HTML>
<html lang="en">
  <head>
    <meta charset="UTF-8"/>
    <title>b!ip</title>
  </head>
  <body bgcolor="#0000FF">
    <?php
      date_default_timezone_set('Europe/London');
      $searchQuery = "SELECT * FROM messages";
      $searchResults = mysql_query($searchQuery);
      $firstnameData = mysql_result($searchResults, 0, 'forename'); 
      $lastnameData = mysql_result($searchResults, 0, 'surname');
      $messageData = mysql_result($searchResults, 0, 'message');
      $datetimeData = mysql_result($searchResults, 0, 'datetime');
      if(isset($_POST["submit"]))
      {
        $firstname = $_POST["forename"];
        $surname = $_POST["surname"];
        $message = $_POST["message"];
        $datetime = date('Y-m-d H:i:s');
        mysql_query("UPDATE messages SET `forename` = '$firstname' WHERE `id` = '1'");
        mysql_query("UPDATE messages SET `surname` = '$surname' WHERE `id` = '1'");
        mysql_query("UPDATE messages SET `message` = '$message' WHERE `id` = '1'");
        mysql_query("UPDATE messages SET `datetime` = '$datetime' WHERE `id` = '1'");
      }
      // date_default_timezone_set('Europe/London');
      // echo date('Y-m-d H:i:s');
    ?>
    <center>
      <table cellpadding="0" cellspacing="0" width="100%" height="50">
        <!-- MSCellFormattingTableID="12" -->
        <tr>
            <td height="50" width="100%">
            <!-- MSCellFormattingType="content" -->
            <p align="center"><font face="Comic Sans MS" color="#FFFFFF">
            <span style="font-size: 60pt">b!ip</span></font></td>
        </tr>
        </table>
    </center>
        <table cellpadding="50" cellspacing="0" width="100%" height="50%">
            <tr>
                <td height="50" width="100%">
                    <form action="#" method="POST">
                        <center><p><font color="#FFFFFF">First name: <input type="text" name="forename"/>   
                        Last name: <input type="text" name="surname"/>   
                        Message: <input type="text" name="message"/>    
                        <input type="submit" value="Send" name="submit"/></font></p></center>
                    </form>
                </td>
            </td>
        </table>
        <table cellpadding="50" cellspacing="0" width="100%" height="50%">
            <tr>
                <td height="50" width="100%">
                    <center><h1><font color="#FFFFFF" face="Comic Sans MS"><?php echo "$messageData <strong>by $firstnameData $lastnameData at $datetimeData</strong>"; ?></font></h1></center>
                </td>
            </td>
        </table>
  </body>
</html>
 
    