title: How to create a success message within a div upon successful form submission?
body: <p>The following form displays the success message every time on page launch in the browser logically but the form should display the success message only after it is submitted successfully.</p>
  
  <pre><code>$editFormAction = $_SERVER['PHP_SELF'];
  if (isset($_SERVER['QUERY_STRING'])) {
  $editFormAction .= "?" . htmlentities($_SERVER['QUERY_STRING']);
  }
  
  $message = "Record has been updated successfully.";
  
  if ((isset($_POST["MM_update"])) &amp;&amp; ($_POST["MM_update"] == "form1")) {
  $updateSQL = sprintf("UPDATE table SET name=%s, email=%s, 
  
                     GetSQLValueString($_POST['name'], "text"),
                     GetSQLValueString($_POST['email'], "text"),
  
  mysql_select_db($database_test, $test);
  $Result1 = mysql_query($updateSQL, $test) or die(mysql_error()); 
  
  $updateGoTo = "test.php";
  if (isset($_SERVER['QUERY_STRING'])) {
  $updateGoTo .= (strpos($updateGoTo, '?')) ? "&amp;" : "?";
  $updateGoTo .= $_SERVER['QUERY_STRING'];
  }
  header(sprintf("Location: %s", $updateGoTo));
  }
  </code></pre>
  
  <p>The html part of the form is as following:</p>
  
  <pre><code>&lt;form action="&lt;?php echo $editFormAction; ?&gt;" method="post" name="form1" id="form1"&gt;
   &lt;table align="center" class="test_table"&gt;
    &lt;tr valign="baseline"&gt;
       &lt;td align="right" nowrap="nowrap" class="table-title"&gt;Name:&lt;/td&gt;
       &lt;td class="table-content"&gt;&lt;input type="text" name="name" value="&lt;?php echo htmlentities($row_user['name'], ENT_COMPAT, 'utf-8'); ?&gt;" size="32" /&gt;&lt;/td&gt;
     &lt;/tr&gt;
     &lt;tr valign="baseline"&gt;
       &lt;td align="right" nowrap="nowrap" class="table-title"&gt;E-mail:&lt;/td&gt;
       &lt;td class="table-content"&gt;&lt;input type="text" name="email" value="&lt;?php echo htmlentities($row_user['email'], ENT_COMPAT, 'utf-8'); ?&gt;" size="32" /&gt;&lt;/td&gt;
     &lt;/tr&gt;
   &lt;/table&gt;
   &lt;input type="hidden" name="MM_update" value="form1" /&gt;
   &lt;input type="hidden" name="id" value="&lt;?php echo $row_user['id']; ?&gt;" /&gt;
    &lt;input class="submit" name="UpdateRecord" type="submit" id="UpdateRecord" value="Update Record" /&gt;&lt;/form&gt;
  </code></pre>
  
  <p>This is how the success message is displayed within a div on the page:</p>
  
  <pre><code>&lt;p&gt; &lt;?php 
    if (!empty($message)) {
    echo "&lt;div class=\"successmessage\"&gt;" . $message . "&lt;/div&gt;";
    } 
    ?&gt;&lt;/p&gt;
  </code></pre>
  
  <p>What I'm doing wrong here?</p>