How to Create HTML File from Textarea Input

mitey 03 Sep, 2012
Hi everyone, I've been using chronoforms for a while now, but I don't have too much time to figure this out. So I need you help.

I have a form that can be used to both save and edit info from a database table. What I want want to do now is to save the input from a textarea in the form into an HTML file in the file system whenever a new entry or an update is made.

I'm using a Custom Code action placed after the database save action with the following code:
<?php
$file_name = $form->data['cf_id'].'-'.JFilterOutput::stringURLSafe($form->data['title'].'.html';
$form->data['html_path'] = $file_name;

$html_file = 'images/docs/'.$file_name;
$handle = fopen($html-file, 'w') or die("can't open file");
$content = '<html>
		<head>
			<title>'.$form->data['title'].' </title>
		</head>
		<body bgcolor="#FFFFFF">
			<div id="content" style="width:700px;margin-left:auto;margin-right:auto;">
				<div id="header">
					<span style="width:100%;border-bottom:solid 1px #000;font-size:18px;font-family:Tahoma,Arial;">'.JFilterOutput::stringURLSafe($form->data['title'].' - <em>'.JFilterOutput::stringURLSafe($form->data['category']).'</em>
					</span><br />
					<div style="font-family:Arial;font-size:13px;"><em>by '.JFilterOutput::stringURLSafe($form->data['speaker']).'</em> | Delivered on '.date('l, F jS Y',$form->data['date']).'</div>
				</div>
				<div id="main" style="font-size:14px;font-family:Times;padding:5px;border:1px solid #000;">'.JFilterOutput::stringURLSafe($form->data['notes']).'
				</div>
				<div id="footer" style="margin-top:5px;font-family:Arial;font-size:12px;">© '.date('Y').' A Publication of <strong>The Redeemer\'s Academy</strong>. All rights reserved		</div>
			</div>
		</body>
	</html>';
$content = trim($content);
fwrite($handle, $content);
fclose($handle);
?>


Any help will be appreciated.
Max_admin 03 Sep, 2012
Your $html_file var may be wrong, try to include the full file path using:
JPATH_SITE.DS


Regards,
Max
Max, ChronoForms developer
ChronoMyAdmin: Database administration within Joomla, no phpMyAdmin needed.
ChronoMails simplifies Joomla email: newsletters, logging, and custom templates.
This topic is locked and no more replies can be posted.