title: Alert user without refreshing the page in PHP
body: <p>I have a php code that alerts when a user delete a record, but it refreshes the page upon alerting, then the background page become blank, which seems quite annoying. How will I do it without refreshing the page? Below is my sample code named deleteuser.php.</p>
  
  <pre><code>&lt;?
  include 'mysqlcon.php'; // my connection credentials to php
  
  $postudel = $_POST['enterudel'];
  
  if($postudel!="")
      {
      $sqldel = "DELETE FROM User WHERE UserName = '$postudel'";
      $getdel = mysql_query($sqldel,$con) or die(mysql_error());
      echo "&lt;script language='javascript'&gt;";
      echo "alert('User $postudel successfully deleted.');";
      echo "&lt;/script&gt;";
      }
  ?&gt;
  
  &lt;html&gt;
  &lt;head&gt;
  &lt;title&gt;Delete User&lt;/title&gt;
  
  &lt;SCRIPT language=JavaScript&gt;
  function deluser()
  {
  var r=confirm("Are you sure you want to do this?");
  if (r==true)
      {
      var objsel = document.getElementById("duser");
      var udel = objsel.options[objsel.selectedIndex].id;
      document.formdel.enterudel.value = udel;
      document.formdel.submit();
      }
      else
      return false;
  }
  &lt;/script&gt;
  &lt;/head&gt;
  
  &lt;body&gt;
  &lt;table width="50%" align="left"&gt;
  &lt;tr&gt;&lt;td width="50%" colspan="2"&gt;
  &lt;big&gt;Delete User:&lt;/big&gt;
  &lt;/td&gt;&lt;/tr&gt;
  
  &lt;tr&gt;&lt;td width="25%"&gt;
  Username:&amp;nbsp;
  &lt;SELECT id="duser"&gt;
  &lt;option&gt;Choose One&lt;/option&gt;
  &lt;?
  $sqldu=mysql_query("SELECT UserName from User");
  
  while($row=mysql_fetch_array($sqldu))
  {
      echo "&lt;OPTION ID=".$row['UserName'];
      echo "&gt;".$row['UserName']."&lt;/OPTION&gt;";
  }
  ?&gt;
  &lt;/SELECT&gt;
  &lt;/td&gt;
  
  &lt;td width="25%"&gt;
  &lt;input type="button" value="Delete" id="delete" onClick="deluser()"&gt;
  &lt;/td&gt;&lt;/tr&gt;
  &lt;/table&gt;
  
  &lt;form name="formdel" action="../deleteuser.php" method="post"&gt;
  &lt;input type="hidden" name="enterudel" value="&lt;?=$postudel?&gt;"&gt;
  &lt;/form&gt;
  
  &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>