Author Archives: ram

About ram

Engaged with Web Development

Advance Password Strength Check Using jQuery

For every log in and registration form the password is more peculiar and important one. User also expect their password should be strength.The password can’t be easily guess by any one.The user may expect their password would be short or weak or good or strong. The password strength can be check using PHP, JavaScript, Ajax, jQuery. But we choose jQuery because jQuery is Advanced Scripting langauge. Here we check given password should be in 4 categories such as Too Short, Weak, Good  and Strength. In the same time we remind you we already discuss about

Let’s we check how the given password is  Too Short, Weak, Good  and Strength. Before that just download  jquery.min.js .Click here Form design for Advance password strength check using jQuery

The Form design for advanced password strength check should be

Advanced password strength check

Advanced password strength check

index.php

[code type=html]

<!DOCTYPE HTML>
<html>
<head>
<meta http-equiv=”content-type” content=”text/html; charset=utf-8″ />
<title>Advanced Password Strength Checking Using jQuery</title>
<script src=”jquery.min.js”></script>
<link rel=”stylesheet” type=”text/css” href=”style.css” />
<script src=”script.js”></script>
</head>

<body>
<div id=”container”>
<div id=”header”>
<h2>Advanced Password Strength Checking Using jQuery<h2>
</div>
<div id=”content”>
<!– form start–>
<form name=”pass_strength”>
<p><label for=”username”>Username : </label>
<input type=”text” name=”username” class=”input” />
</p>
<p><label for=”password”>Password : </label>
<input type=”password” name=”password” id=”password” class=”input” />
<span id=”result”></span>
</p>
</form>
<!– form end–>
</div>
<div id=”footer”>
<p align=”center”>Powered by &nbsp;&nbsp; <a href=”http://www.byzerotechnologies.com/” target=”_blank”>Byzero Technologies</a></p>
</div>

</div>
</body>
</html>

[/code]

Password strength to be calculated by following  jQuery coding

script.js

[code type=php]

$(document).ready(function() {

$(‘#password’).keyup(function(){
$(‘#result’).html(checkStrength($(‘#password’).val()))
})

function checkStrength(password){

//strength at begining
var strength = 0

//when password is less than 6 means
if (password.length < 6) {
$(‘#result’).removeClass()
$(‘#result’).addClass(‘short’)
return ‘Too short’
}
// when password length is 8 or more
if (password.length > 7) strength += 1

//when password contain both uppercase and lowercase character means
if (password.match(/([a-z].*[A-Z])|([A-Z].*[a-z])/)) strength += 1

//when password contain both character and number means
if (password.match(/([a-zA-Z])/) && password.match(/([0-9])/)) strength += 1

//when password contain one special character means
if (password.match(/([!,%,&,@,#,$,^,*,?,_,~])/)) strength += 1

//when password two or more special character means
if (password.match(/(.*[!,%,&,@,#,$,^,*,?,_,~].*[!,%,&,@,#,$,^,*,?,_,~])/)) strength += 1

//now we have calculated strength value, we can return messages

//if value is less than 2
if (strength < 2 ) {
$(‘#result’).removeClass()
$(‘#result’).addClass(‘weak’)
return ‘Weak’
} else if (strength == 2 ) {
$(‘#result’).removeClass()
$(‘#result’).addClass(‘good’)
return ‘Good’
} else {
$(‘#result’).removeClass()
$(‘#result’).addClass(‘strong’)
return ‘Strong’
}
}
});

 

[/code]

style.css [stylesheet]

[code type=css]

body
{
background-color:#CCC;
font-family:”Arial;”, Gadget, sans-serif;
}

#container
{

padding:20px 20px 0px 20px;
width:42%;
background-color:#27AECB;
margin:0 auto;
border:5px solid #FFF;
box-shadow: 0px 0px 20px rgb(29, 133, 230);
margin-top:150px;
}
#content
{
margin: 0px 100px 0px 100px;
padding:10px;
border: 2px solid rgb(105, 91, 91);
box-shadow: 2px 2px 10px #FFF;
background: #CCC;
}
.input
{
margin:10px;

}
#result
{
color:#F00;
text-shadow:#666;
}
#footer
{
width:76%;
margin:20px 70px 20px 70px;
background:#000;
box-shadow:2px 2px 10px #666666;
color:#FFF;
}
a
{
color:#06F;
}

[/code]

Download the Advance password strength check using jQuery click here to download

Check existing Password in Ajax and change the Password

Analyze the existing password from database without refresh using ajax concept. The given password is compared with existing password in database and display whether it is correct or not. Here Ajax is used to analyze or check the exisiting password with  The HTML, Ajax,Mysql coding are provided below.You can try if you need to check existing password and change password using Ajax.

 

 

Table structure for table `change_password`

[code type=html]
CREATE TABLE IF NOT EXISTS `change_password` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`username` varchar(50) NOT NULL,
`password` varchar(50) NOT NULL,
`confirm_password` varchar(50) NOT NULL,
PRIMARY KEY (`id`)
)
INSERT INTO `change_password` (`id`, `username`, `password`, `confirm_password`) VALUES
(1, ‘ramkumar’, ‘123’, ‘123’);
[/code]

Change_password.php

[code type=html]

<?php

include(“conn.php”);
if(isset($_POST[‘submit’]))
{
$password=mysql_real_escape_string($_POST[‘password’]);
$confirmpasssword=mysql_real_escape_string($_POST[‘confirmpassword’]);
if($password==$confirmpasssword)
{
$insert=(“update change_password set password=’$confirmpasssword’, confirm_password=’$confirmpasssword’ where username=’ramkumar'”);
$insert1=mysql_query($insert);
echo “<script> alert(‘Your password is changed’);</script>”;
}
else
{
echo “<script> alert(Your password is changed);</script>”;
}
}
?>

<html>
<head>
<title>Change Password</title>
<script type=”text/javascript”>
function showUser(str)
{
if (str==””)
{
document.getElementById(“txtHint”).innerHTML=””;
return;
}
if (window.XMLHttpRequest)
{// code for IE7+, Firefox, Chrome, Opera, Safari
xmlhttp=new XMLHttpRequest();
}
else
{// code for IE6, IE5
xmlhttp=new ActiveXObject(“Microsoft.XMLHTTP”);
}
xmlhttp.onreadystatechange=function()
{
if (xmlhttp.readyState==4 && xmlhttp.status==200)
{
document.getElementById(“txtHint”).innerHTML=xmlhttp.responseText;
}
}
xmlhttp.open(“GET”,”check_password.php?q=”+str,true);

xmlhttp.send();
}
</script>

<script type=”text/javascript”>
function pass()
{
var pwd=document.getElementById(“password”).value;
var cpwd=document.getElementById(“confirmpassword”).value;
if(pwd==cpwd)
{
var t1=document.getElementById(‘pass’).innerHTML=”Password Match”;

/*t1.style.display=’block’;*/
}
else
{
var t1=document.getElementById(‘pass’).innerHTML=”Password does not Match”;
/* t1.style.display=’block’;*/
document.form.password.focus();
}
}
</script>

<style type=”text/css”>

body
{
}
.table
{
color:#000000;
}
.st
{
color:#FF0000;
}
</style>
</head>
<form id=”form” name=”form” method=”post” action=”” onSubmit=”return passvali();”>
<table width=”50%” border=”0″ cellspacing=”0″ cellpadding=”5″ align=”center” bgcolor=”#C1C1FF”>
<tr>
<td colspan=”2″ align=”center”> <h2>Change Password</h2></td>
</tr>
<tr>
<th> Current Password <span style=”color:#F00;”>*</span></th>
<td><input type=”password” name=”cur_pwd” class=”input”id=”oldpassword”placeholder=”Enter Current Password” onChange=”showUser(this.value)” /></td>
<td> <span class=”st” id=”txtHint”></span> </td>
</tr>
<tr>
<th>New Password <span style=”color:#F00;”>*</span></th>
<td><input type=”password” name=”password” class=”input” id=”password” placeholder=”Enter your Password”/></td>
</tr>
<tr>
<th> Confirm Password <span style=”color:#F00;”>*</span></th>
<td><input type=”password” name=”confirmpassword” class=”input” id=”confirmpassword” placeholder=”Enter Confirm Password” onChange=”return pass()” /></td>
<td><span id=”pass” style=”color:#F00;”> </span> </td>
</tr>
<tr>
</tr>
<tr>
<td colspan=”2″ align=”center”><input type=”submit” name=”submit” value=”Submit” style=”width:80px;” /></td>
</tr>
</table>
</form>

</body>

</html>

[/code]

check_password.php

[code type=html]

<?php
include(‘conn.php’);
$password=$_GET[‘q’];
$select=mysql_query(“select * from change_password where username=’ramkumar'”);
$fetch=mysql_fetch_array($select);
$data_pwd=$fetch[‘password’];

if($data_pwd==$password)
{
echo “Password match”;
}
else
{
echo “provide valid password”;
}
?>

[/code]

Form Design

change_password

 Password Checking from database using Ajax: 

ajax

 Password Matching:

password_match

 

Javascript and jquery validation for Tab

Tabs uses for  quick loading and load the page content without page refresh. In Tab the form validation can be done using through javascript and jquery concepts. From following coding the form can validated. Just include the jquery css file and min.js file  provided below. You can change or add newfiled for validation by adding filedname and alert message in jquery coding.

Download the files and include in head : javascript and jquery validation for tab

Javascript and jquery validation for Tab

Javascript and jquery validation for Tab

 

tab.php

[code type=html]

<form id=”custom”>
<fieldset title=”Tab 1″>
<legend>step 1</legend>
<label>User:</label>
<!– Hidden fields are not focused. –>
<input type=”hidden” name=”hidden” />
<!– Disabled fields are not validated. –>
<input type=”text” value=”wbotelhos” size=”40″ name=”user” disabled=”disabled” />
<label>E-mail:</label>
<input type=”text” size=”40″ name=”email” />
<input type=”checkbox” name=”checked” /> Checked?
<label>Newsletter?</label>
<input type=”radio” name=”newsletter” /> Yep
<input type=”radio” name=”newsletter” /> Nop
<label>Password:</label>
<input type=”password” name=”password” size=”40″ />
</fieldset>

<fieldset title=”Thread 2″>
<legend>description two</legend>
<label>Nick Name:</label>
<input type=”text” size=”30″ />
<label>Bio:</label>
<textarea name=”bio” rows=”5″ cols=”60″></textarea>
</fieldset>

<fieldset title=”Thread 3″>
<legend>description three</legend>
<label>Birthday:</label>
<select name=”day”>
<option></option>
<option>23</option>
</select>
<select>
<option>10</option>
</select>
<select>
<option>1984</option>
</select>
<label>Site:</label>
<input type=”text” name=”site” size=”40″ />
</fieldset>

<input type=”submit” class=”finish” value=”Finish!” />
</form>

[/code]

Jquery validation: If you add new filed you need to validate it just add name and alert message for the name wrong.

[code type=html]

<script type=”text/javascript”>
$(function() {

$(‘#default’).stepy();

$(‘#custom’).stepy({
backLabel: ‘Backward’,
block: true,
errorImage: true,
nextLabel: ‘Forward’,
titleClick: true,
validate: true
});

$(‘div#step’).stepy({
finishButton: false
});

// Optionaly
$(‘#custom’).validate({
errorPlacement: function(error, element) {
$(‘#custom div.stepy-error’).append(error);
}, rules: {
‘user’: { maxlength: 1 },
’email’: ’email’,
‘checked’: ‘required’,
‘newsletter’: ‘required’,
‘password’: ‘required’,
‘bio’: ‘required’,
‘day’: ‘required’
}, messages: {
‘user’: { maxlength: ‘User field should be less than 1!’ },
’email’: { email: ‘Invalid e-mail!’ },
‘checked’: { required: ‘Checked field is required!’ },
‘newsletter’: { required: ‘Newsletter field is required!’ },
‘password’: { required: ‘Password field is requerid!’ },
‘bio’: { required: ‘Bio field is required!’ },
‘day’: { required: ‘Day field is requerid!’ }
}
});

$(‘#callback’).stepy({
back: function(index) {
alert(‘Going to step ‘ + index + ‘…’);
}, next: function(index) {
if ((Math.random() * 10) < 5) {
alert(‘Invalid random value!’);
return false;
}

alert(‘Going to step ‘ + index + ‘…’);
}, select: function(index) {
alert(‘Current step ‘ + index + ‘.’);
}, finish: function(index) {
alert(‘Finishing on step ‘ + index + ‘…’);
}, titleClick: true
});

$(‘#target’).stepy({
description: false,
legend: false,
titleClick: true,
titleTarget: ‘#title-target’
});

});
</script>

[/code]

Include the following file in your <head> tags. Download the below file in below  link.

[code type=html]

<link type=”text/css” rel=”stylesheet” href=”jquery.stepy.css” />
<script type=”text/javascript” src=”jquery.min.js”></script>
<script type=”text/javascript” src=”jquery.validate.min.js”></script>
<script type=”text/javascript” src=”jquery.stepy.min.js”></script>

[/code]

Download the files here: javascript and jquery validation for tab

Page look like this…

 

Javascript validation for File uploading format

Upload file can be validate through javascript . By onclick, onchange, onsubmit we can do this validation. File extension can be analyzed  through below coding. You can change the file extension basis on your  requirement.Validation also for submit without any file selection.This javascript validation is simple and useful .

Javascript

[code type=html]

<script type=”text/javascript”>

function file_upload()
{
var imgpath = document.getElementById(‘word’).value;
if(imgpath == “”)
{
alert(“upload your word file”);
document.file.word.focus();
return false;
}
else
{
// code to get File Extension..
var arr1 = new Array;
arr1 = imgpath.split(“\\”);
var len = arr1.length;
var img1 = arr1[len-1];
var filext = img1.substring(img1.lastIndexOf(“.”)+1);
// Checking Extension
if(filext == “doc” || filext == “docx”)
{
alert(“File has been upload correctly”)
return false;
}
else
{
alert(“Invalid File Format Selected”);
document.form.word.focus();
return false;
}
}
}
</script>

[/code]

fileupload.php

Untitled

[code type=html]

<form name=”fileupload” onsubmit=”return file_upload();”>
<table align=”center” bgcolor=”#8080FF” height=”100″>
<tr>
<th> Fileupload:</th>
<td> <input type=”file” name=”word” id=”word” > </td>
</tr>
<tr>
<td> <input type=”submit” /> </td>
</tr>
</table>
</form>

[/code]

This alert message for invalid file format

1

This alert message will come when u choose correct file format.

2

 

 

 

Automatically Display (or) Convert a Number into Word(String) Using PHP

Here we have to discuss about the thing how to convert automatically a number as string(word) using PHP. We already discuss the things in  conversion of current webpage as MS-Word document and PDF file. Similar to this conversion we going to convert a number as word(string). It  is also used in the application projects. Most of the billing system required automatically generate the total amount in word after entering the total amount. Similar to this most of webpage need to convert the entering number into word(string).

There is three cases in conversion of word. We able to convert the number as word(string) in following cases.

  • Upper Case
  • Lower Case
  • Camel Case

syntax

[code type= php]

strtoupper(convertNumber($num))

strtolower(convertNumber($num))

ucwords(convertNumber($num))

[/code]

Let’s see the simple example”

Automatically display(or) Convert a number into string using php

[code type = php]

<!DOCTYPE html>
<html lang=”en”>
<head>
<meta charset=”utf-8″>
<title>Example for Automatically Display (or) Convert a Number into String Using PHP</title>
<meta name=”description” content=”Example of converting number to word with PHP”>

<style type=”text/css”>

.well {
width: 500px;
}

.well h2 {
margin-bottom: 20px;
}

.well p {
color: #bf0000;
}

button[type=’submit’] {
display: block;
}
.container
{
background:#99B1F2;
width:400px;
height:200px;
text-align:justify;
padding:10px;
}

</style>

</head>
<body>
<center>
<div class=”container”>
<h2>Enter a number to convert it in words</h2>
<form class=”well” method=”POST” action=” ” >
<label>Enter a Number:</label>
<input type=”text” class=”span3″ name=”num” placeholder=”Enter a number”></br></br>
<label>Output Format:</label>
<select name=”cases”>
<option value=”uc”>All upper case</option>
<option value=”lc”>All lower case</option>
<option value=”cc”>Camel case</option>
</select>
<button type=”submit” name=”submit” >Submit</button>

</form>

</div>
</center>

</body>
</html>

<?php
/*
Copyright 2007-2008 Brenton Fletcher. http://bloople.net/num2text
You can use this freely and modify it however you want.
*/

/*
w3resource team have modified it to make it nicer coverting cases.
*/

$num = $_POST[‘num’];

if ($_POST[‘cases’] == “uc”)
{
echo “<center><div class=’well’><h2>Your output</h2><p>”.strtoupper(convertNumber($num)).”</p></div></center>”;
}

if ($_POST[‘cases’] == “lc”)
{
echo “<center><div class=’well’><h2>Your output</h2><p>”.strtolower(convertNumber($num)).”</p></div></center>”;
}

if ($_POST[‘cases’] == “cc”)
{
echo “<center><div class=’well’><h2>Your output</h2><p>”.ucwords(convertNumber($num)).”</p></div></center>”;
}

function convertNumber($num)
{
list($num, $dec) = explode(“.”, $num);

$output = “”;

if($num{0} == “-“)
{
$output = “negative “;
$num = ltrim($num, “-“);
}
else if($num{0} == “+”)
{
$output = “positive “;
$num = ltrim($num, “+”);
}

if($num{0} == “0”)
{
$output .= “zero”;
}
else
{
$num = str_pad($num, 36, “0”, STR_PAD_LEFT);
$group = rtrim(chunk_split($num, 3, ” “), ” “);
$groups = explode(” “, $group);

$groups2 = array();
foreach($groups as $g) $groups2[] = convertThreeDigit($g{0}, $g{1}, $g{2});

for($z = 0; $z < count($groups2); $z++)
{
if($groups2[$z] != “”)
{
$output .= $groups2[$z].convertGroup(11 – $z).($z < 11 && !array_search(”, array_slice($groups2, $z + 1, -1))
&& $groups2[11] != ” && $groups[11]{0} == ‘0’ ? ” and ” : “, “);
}
}

$output = rtrim($output, “, “);
}

if($dec > 0)
{
$output .= ” point”;
for($i = 0; $i < strlen($dec); $i++) $output .= ” “.convertDigit($dec{$i});
}

return $output;
}

function convertGroup($index)
{
switch($index)
{
case 11: return ” decillion”;
case 10: return ” nonillion”;
case 9: return ” octillion”;
case 8: return ” septillion”;
case 7: return ” sextillion”;
case 6: return ” quintrillion”;
case 5: return ” quadrillion”;
case 4: return ” trillion”;
case 3: return ” billion”;
case 2: return ” million”;
case 1: return ” thousand”;
case 0: return “”;
}
}

function convertThreeDigit($dig1, $dig2, $dig3)
{
$output = “”;

if($dig1 == “0” && $dig2 == “0” && $dig3 == “0”) return “”;

if($dig1 != “0”)
{
$output .= convertDigit($dig1).” hundred”;
if($dig2 != “0” || $dig3 != “0”) $output .= ” and “;
}

if($dig2 != “0”) $output .= convertTwoDigit($dig2, $dig3);
else if($dig3 != “0”) $output .= convertDigit($dig3);

return $output;
}

function convertTwoDigit($dig1, $dig2)
{
if($dig2 == “0”)
{
switch($dig1)
{
case “1”: return “ten”;
case “2”: return “twenty”;
case “3”: return “thirty”;
case “4”: return “forty”;
case “5”: return “fifty”;
case “6”: return “sixty”;
case “7”: return “seventy”;
case “8”: return “eighty”;
case “9”: return “ninety”;
}
}
else if($dig1 == “1”)
{
switch($dig2)
{
case “1”: return “eleven”;
case “2”: return “twelve”;
case “3”: return “thirteen”;
case “4”: return “fourteen”;
case “5”: return “fifteen”;
case “6”: return “sixteen”;
case “7”: return “seventeen”;
case “8”: return “eighteen”;
case “9”: return “nineteen”;
}
}
else
{
$temp = convertDigit($dig2);
switch($dig1)
{
case “2”: return “twenty-$temp”;
case “3”: return “thirty-$temp”;
case “4”: return “forty-$temp”;
case “5”: return “fifty-$temp”;
case “6”: return “sixty-$temp”;
case “7”: return “seventy-$temp”;
case “8”: return “eighty-$temp”;
case “9”: return “ninety-$temp”;
}
}
}

function convertDigit($digit)
{
switch($digit)
{
case “0”: return “zero”;
case “1”: return “one”;
case “2”: return “two”;
case “3”: return “three”;
case “4”: return “four”;
case “5”: return “five”;
case “6”: return “six”;
case “7”: return “seven”;
case “8”: return “eight”;
case “9”: return “nine”;
}
}

?>

[/code]

Category: PHP

Convert (or) Save current Webpage as PDF document Using PHP

Here we have to see how to convert (or) current webpage as pdf file. We already discuss the thing about conversion of webpage as MS-Word document file. Similar to this we have to convert current webpage as pdf  on current  webpage itself. Most of the  websites willing to provide their document as pdf instead MS-Word because in pdf the data can’t be changed by user. From this information from pdf is unique. So most of website add a link to download as pdf. Let see how it can developed in php.

For designing and import content of webpages  we have include the coding of pdf toolkit here.Download the pdf creator html2fpdf  add extract the files and  add few files in the html2fpdf folder.

  • The download link for pdf creator toolkit is html2fpdf
  • save this file as form.php in downloaded html2fpdf  folder.

[code type = php]

<!DOCTYPE html PUBLIC “-//W3C//DTD XHTML 1.0 Transitional//EN” “http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd”>
<html xmlns=”http://www.w3.org/1999/xhtml”>

<head>
<meta http-equiv=”Content-Type” content=”text/html; charset=utf-8″ />
<title>Untitled Document</title>
</head>

<body>

<fieldset style=”background-color:#6C6CFF; height:400px; padding:20px;”>
<center><form method=”post” action=”pdf.php”>
<p>Here we have to see how to convert (or) current webpage as pdf file. We already discuss the thing about conversion of webpage as MS-Word document file. Similar to this we have to convert current webpage as pdf on current webpage itself. Most of the websites willing to provide their document as pdf instead MS-Word because in pdf the data can’t be changed by user. From this information from pdf is unique. So most of website add a link to download as pdf. Let see how it can developed in php.For designing and import content of webpages we have include the coding of pdf toolkit here.Download the pdf creator html2fpdf add extract the files and add few files in the html2fpdf folder.The download link for pdf creator toolkit is html2fpdf</p>
<input type=”submit” name=”submit” />
</form>
</center>
</fieldset>

</body>
</html>

[/code]

  • The above  form is  we have to downloaded as pdf.
  • so, now we have link a form.php to fpdf.php which is pdf format  maker (or) creator.
  • Create and save the file as pdf.php in html2pdf folder itself.

[code type=php]

<?php
require(“html2fpdf.php”);

$htmlFile = “form.php”;
$buffer = file_get_contents($htmlFile);

$pdf = new HTML2FPDF(‘P’, ‘mm’, ‘Letter’);
$pdf->AddPage();
$pdf->WriteHTML($buffer);
$pdf->Output(‘test.pdf’, ‘F’);

?>

[/code]

  • By executing pdf.php file we get a current webpage as pdf format in the name of test.pdf.
  • Check the foder html2fpdf there is a test.pdf fle which contain the content of form.php file.
Category: PHP

Convert (or) Save current Webpage as MS-Word document Using PHP

Here we have to see about how to convert (or) save a current webpage as Microsoft word document format. Most of the website willing to provide their webpages in MS-Word format for their user.Most of the application sites, Government sites are made their MS-Word file from current webpage.

First of all previous methods used for conversion of  Webpage as MS-Word Documents are

  • There is toolkit using for conversion of Webpage into MS-Word .
  • By storing the webpage content in MS-word format and by clicking submit button they word has to be download from database.

Here is simple method used to convert as  MS-Word from Webpage by adding two header file lines with in application concept.The whole content of the webpage should in the MS-Word file.

[code type=php]

header(“Content-type: application/vnd.ms-word”);
header(“Content-Disposition: attachment; Filename=SaveAsWordDoc.doc”);

[/code]

Convert current webpage as MS-Word document on the form itself.

Here let we see simple example for this MS-Word Conversion.

syntax

[code type=php]

<!DOCTYPE html PUBLIC “-//W3C//DTD XHTML 1.0 Transitional//EN” “http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd”>
<html xmlns=”http://www.w3.org/1999/xhtml”>
<head>
<meta http-equiv=”Content-Type” content=”text/html; charset=utf-8″ />
<title>Webpage to MS-Word file</title>
</head>
<body>

<fieldset style=”background-color:#666; height:200px; padding:20px;”>
<center>
<form method=”post” action=” “>
<p>
Here we have to see about how to convert (or) save a current webpage as Microsoft word document format.Most of the website willing to provide their webpages in MS-Word format for their user.Most of the application sites, Government sites are made their MS Word file from current webpage.First of all previous methods used for conversion of Webpage as MS-Word Documents are 1.There is toolkit using for conversion of Webpage into MS-Word. 2.By storing the webpage content in MS-word format and by clicking submit button they word has to be download from database. Here is simple method used to convert as MS-Word from Webpage by adding two header file lines with in application concept.

</p>

<input type=”submit” name=”submit” />
</form>
</center>
</fieldset>

<?php
if(isset($_POST[‘submit’]))
{
header(“Content-type: application/vnd.ms-word”);
header(“Content-Disposition: attachment; Filename=SaveAsWordDoc.doc”);
}
?>

[/code]

Category: PHP