Home: htmlArea 2: htmlArea 2 & 3 archive (read only): htmlArea v2.0 - Add-Ons:
TRYING: Simple OPEN, EDIT and SAVE (php)

New User

Jun 12, 2004, 7:42 PM

Views: 44213
TRYING: Simple OPEN, EDIT and SAVE (php)


I am trying to create a simple open, edit and save feature for my pages using php and htmlarea
but I seem to be having problems.

Problem One: I can only get it to edit the whole page were I would like to change this and specify
the area in which to change, while still saving the rest of the page

Problem Two: I have the page saving (full page) but it is cutting out the html, head top tags
and the bottom body and html tags.

Code is Below, anyone able to help me out here?



$file = "$filename";
$fs = fopen( $file, "a+" ) or die("error when opening the file");

while (!feof($fs)) {
$contents .= fgets($fs, 1024);


<script language="Javascript1.2"><!-- // load htmlarea
_editor_url = "/htmlarea/"; // URL to htmlarea files
var win_ie_ver = parseFloat(navigator.appVersion.split("MSIE")[1]);
if (navigator.userAgent.indexOf('Mac') >= 0) { win_ie_ver = 0; }
if (navigator.userAgent.indexOf('Windows CE') >= 0) { win_ie_ver = 0; }
if (navigator.userAgent.indexOf('Opera') >= 0) { win_ie_ver = 0; }
if (win_ie_ver >= 5.5) {
document.write('<scr' + 'ipt src="' +_editor_url+ 'editor.js"');
document.write(' language="Javascript1.2"></scr' + 'ipt>');
} else { document.write('<scr'+'ipt>function editor_generate() { return false; }</scr'+'ipt>'); }
// --></script>
<form action="save.php" method="post">
<input type=hidden name="file" value="<?php echo $file; ?>">
<textarea name="contents" style="width:700; height:550"><?php echo htmlspecialchars($contents); ?></textarea>
<script language="javascript1.2">
<input type="submit" value="SAVE">


$fs = fopen( $_POST["file"], "w+" ) or die("error when opening the file");
fwrite($fs, $_POST["contents"]);


Jun 14, 2004, 2:03 PM

Views: 44179
Re: [elogicmedia] TRYING: Simple OPEN, EDIT and SAVE (php)

Hi, this is the way I show my pages:

I save the stuff created with htmlarea directly into a file (I strip slashes with PHP's stripslashes-function). Let's say this file is called htmlarea.html.

The page that I want to show my htmlarea text is called showhtml.php. It contains the following code

<? include "htmlarea.html"; ?>

This way you can insert the necessary HTML and BODY tags for the page. And they don't show up when you open htmlarea.html for editing.

Hope that helps,

New User

Feb 16, 2005, 1:23 PM

Views: 43548
Re: [tuusita] TRYING: Simple OPEN, EDIT and SAVE (php)

Dear tuusita,

I just found your answer and as this is my question as well and I am absolutely new to HTMLarea, I am looking for a way to open always the same file in the HTML-Area, edit it and save it so it can be included in another php-file.

If I understood you right, that's what you are doing.
Could you help with your script? I am so new to this, but I am not new to PHP completely,

thanks in advance,



Feb 18, 2005, 8:29 AM

Views: 43483
Re: [Connie] TRYING: Simple OPEN, EDIT and SAVE (php)


Just a quick and dirty reply (it's been a long time since I've worked with HTMLArea...). Please don't get upset with me if my scripts don't work as-is. It's been a while. Smile

The way I solved this was that I saved the text coming from HTMLArea form to a file of its own (say content.html) with a php-script.
Then I created a very simple php-file like this:


<% include "content.html"; %>

(end show.php)

So you see I put the base HTML-code of the page in that php-file and just included the file that holds the content created with HTMLArea.
Oh, if I recall correctly you need to stripslashes from the HTMLArea-content before saving.

Like this:

 $data = stripslashes($HTTP_POST_VARS["etusivu"]);

Then save then contents of the $data-variable to the contents.html

I wrote this in a hurry, sorry for any mistakes... Smile

Teemu Uusitalo