Convert HTML to MS Word Document using PHP
PHP SCRIPT TO DO THE CONVERSION
<?php
// Check to be sure that the only request we can process is a POST REQUEST
if(isset($_SERVER["REQUEST_METHOD"]) && strip_tags($_SERVER["REQUEST_METHOD"]) == strip_tags("POST"))
{
if(isset($_POST['create_ms_word']))
{
// If all fields in index.php page are filled, procceed to process the data
if(isset($_POST['topic']) && !empty($_POST['topic']) && isset($_POST['content']) && !empty($_POST['content']))
{
// Below are data sent from the index.php page
$output ="
<h1>".$_POST['topic']."</h1>
<p>".nl2br($_POST['content'])."</p>
";
$filename = date("d-m-Y").'.doc'; // This is the name of our MS Word file that will be created
header("Cache-Control: ");// leave blank to avoid IE errors
@header("Pragma: ");// leave blank to avoid IE errors
header("Expires: 0");
header("Content-Type: application/vnd.msword"); // Creates the MS Word Document
header("content-disposition: attachment;filename=".$filename); // Downloads the document
echo "<html>"; // Starts HTML
echo $output; // The body content of our MS Word Document goes in here
echo "</html>"; // Ends the HTML
}
else
{
// If all fields in index.php page are not filled, alert an error message below
echo "<script>alert('Please fill in all the required fields')</script>";
echo "<script>window.location='index.php'</script>";
}
}
else
{
die('Sorry, no proper data was passed');
}
}
else
{
// Deny access if the request brought to this page is not a POST REQUEST
die('Access Denied');
}
?>Screen Shots
Click on a photo below to scroll through the screen shots of the application!
Submit your Job or Project Today!
We can help you turn your idea into reality, take over your existing project, or extend your current development team.
Submit your idea job or project below and we will follow up with you shortly.
OUR OBJECTIVE
Our objective is to reach a place where our services will be highly regarded by businesses from various industrial domains for building their innovative busines solutions with our cutting-edge technological expertise, interactive designs and uncompromised quality.
OUR MISSION
We aspire to help businesses ranging from startups to enterprises, who reach out to us with their requirements, in achieving great lengths, expanding their reach, upscaling their products, and generate a large user-base with our outstanding and cost-effective services.
