Do not want Html after php is executed -


i have following code:

<?php ...  ?>  <script> .... </script>  <html>  ... </html> 

after displaying html form, javascript should validate , php should save in database , give confirmation message.. happens is, after php executed , success message echoed, html form displays below message.. can avoid this?

i prefer set variable if form submission successful. following:

<?php $success = false;  if (isset($_post['submit'])) {     // process form submission     // if submission validates; set $success true } ?> <!doctype html> <html>   <head>     …   </head>   <body> <?php if ($success): ?>     <p>thank submission!</p> <?php else: ?>     <form action="" method="post">       …     </form> <?php endif; ?>   </body> </html> 

Comments

Popular posts from this blog

Django REST Framework perform_create: You cannot call `.save()` after accessing `serializer.data` -

Why does Go error when trying to marshal this JSON? -