andyxfun
08-16-2009, 03:18 AM
is it possible to use a php script to: use an htm page as a template, take the text from a textarea form and insert it at a specific place into the htm page,saving the new formed custom page as another htm page?
what script could i use?:)
fabin
08-16-2009, 12:43 PM
are you looking for some sort of template engine like smarty?
If I understand you correctly, you easily do this using search and replace functions in PHP.
latheesan
08-16-2009, 12:50 PM
Yea, a simple search and replace would work like this:
my_template.htm - simple example
<html>
<head>
<title>%title%</title>
</head>
<body>
<p>
Hello, my name is %name% and i am %age% years old!
</p>
</body>
</html>
and you would process the above html file like this in PHP
index.php - simple example
<?php
// load the contents of template file
$html = file_get_contents('my_template.htm');
// search for the following
$search = array('%title%', '%name%', '%age%');
// replace it with the following
$replace = array('Personel Page', 'Latheesan', 21);
// do the actual search & replace
str_replace($search, $replace, $html);
// print the page
echo $html;
?>