<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8" name="viewport" content="width=device-width, initial-scale=1"/> </head> <body> <nav class="navbar navbar-default"> <div class="container-fluid"> <a class="navbar-brand" href="https://sourcecodester.com">Sourcecodester</a> </div> </nav> <div class="col-md-3"></div> <div class="col-md-6 well"> <h3 class="text-primary">Export HTML Form To MS Word Using PHP Source Code</h3 > <hr style="border-top:1px dotted #ccc;"/> <div class ="col-md-6"> <form action="export.php" method="POST"> <div class="form-group"> <h4>Title</h4> <input type="text" name="title" class="form-control"/> </div> <br /> <div class="form-group"> <h4>Content</h4> <textarea class="form-control" name="content" style="resize:none; height:250px;"></textarea> </div> <button name="export" class="btn btn-primary"><span class="glyphicon glyphicon-export"></span> Export as MS Word</button> </form> </div> </div> </body> </html>
<?php $output =" <h1>".$_POST['title']."</h1> <p>".$_POST['content']."</p> "; echo "<html>"; echo $output; echo "</html>"; }else{ echo "<script>alert('Please complete the required field!')</script>"; echo "<script>window.location='index.php'</script>"; } }; ?>