Pages

Monday, 1 February 2016

How to make HTML File using PHP

If you are familiar with C filing programming then your knowledge will be work here. Just copy and paste the following complete code and implement your logic as you want 

<?php 
if($_POST['submit'])
{
$myfile = fopen($_POST['fnm'].".html", "w") or die("Unable to open file!");
;
fwrite($myfile, $_POST['msg']);
fclose($myfile);
}
?>

<!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=iso-8859-1" />
<title>Girfa : How to make HTML File using PHP</title>
</head>

<body>

<form method="post"  action=<?php echo "$_SERVER[PHP_SELF]" ?>  >
        Enter File Name : <input type="text" name="fnm" /><br /><br />
            Enter file content : <textarea cols="100" rows="25" name="msg"></textarea><br /><br />
            <input type="submit" value="upload"  name="submit" />
            
        </form>
      
</body>
</html>

No comments:

Post a Comment