Quick Search:
CODE
Oracle PL/SQL Code Library
JOBS
Find Or Post Oracle Jobs
FORUM
Oracle Discussion & Chat
 PHP Code: Create an HTML page on demand Jump to:  
Category: >> PHP Code >> Create an HTML page on demand Bookmark and Share

<< lastnext >>

Snippet Name: Create an HTML page on demand

Description: Creating an HTML page on the fly. This could easily be populated from info drawn from a database.

Comment: (none)

Language: PHP
Highlight Mode: PHP
Last Modified: March 01st, 2009

<?PHP
 
//create an html file and redirect to it 
 
//set some basic html content 
$sHTML_Header = "<html><head><title>Test an html page</title></head><body>"; 
$sHTML_Content = "<h2><center>This is a Test Page</center><h2><br /><hr />"; 
$sHTML_Footer =  "</body></html>"; 
 
$filename = "test.html"; 
 
// Let's make sure the file exists and is writable first. 
IF (IS_WRITABLE($filename)) { 
 
   // In our example we're opening $filename in append mode. 
   // The file pointer is at the bottom of the file hence 
   // that's where $somecontent will go when we fwrite() it. 
   IF (!$handle = FOPEN($filename, 'w')) { 
         ECHO "Cannot open file ($filename)"; 
         EXIT; 
   } 
 
   // Write $somecontent to our opened file. 
   IF (FWRITE($handle, $sHTML_Header) === FALSE) { 
       ECHO "Cannot write to file ($filename)"; 
       EXIT; 
   }ELSE{ 
      //file is ok so write the other elements to it 
      FWRITE($handle, $sHTML_Content); 
      FWRITE($handle, $sHTML_Footer); 
   } 
 
   FCLOSE($handle); 
 
}ELSE{ 
   ECHO "The file $filename is not writable"; 
} 
 
//redirect the user to the html page 
HEADER("location:$filename"); 
 
?>
 


Free
Oracle Magazine
Subscriptions
and Oracle White Papers


SQL University.net courses meet the most demanding needs of the business world for advanced education in a cost-effective manner. SQL University.net courses are available immediately for IT professionals and can be taken without disruption of your workplace schedule or processes.

Compared to traditional travel-based training, SQL University.net saves time and valuable corporate resources, allowing companies to do more with less. That's our mission, and that's what we deliver.

Click here to find out more
 
Home      :      Code Library      :      Sponsors      :      Privacy      :      Terms of Use      :      Contact Us 193 users online    © 2009 psoug.org

PSOUG LOGIN
Username: 
Password: 
Forgot your password?