title: How to show alert box after successful data insertion in mysql?
body: <p>I want to show JavaScript alert  after successful data insertion in MySQL. How to do this? I have written this code but it shows JavaScript alert everytime I open this page and as soon as i click on OK of JavaScript alert it redirects me to finalmem.php, without the action of taking values from users!</p>
  
  <pre><code>$sql="INSERT INTO members VALUES ('$name', '$email', '$ybr', '$ach')";
  
  if(!mysqli_query($con,$sql)) 
  {
      die('Error: ' . mysqli_error($con));
  }
  
  else
  {
  
      echo '&lt;script language="javascript"&gt;';
      echo 'alert("Successfully Registered"); location.href="finalmem.php"';
      echo '&lt;/script&gt;';
  }       
  </code></pre>
  
  <p>Thanks in advance.</p>