Jump to content

I need help with this small code...


Exalto

Recommended Posts

Hey.

Can somebody help me with this script? I have 2 pages. First one is a page with a form which shows a source code of .htm file. Second file just writes to a file. If I edit the code and submit form, it should save modifications to the .htm file. The problem is: when I save the changes, all " and ' characters change to /" and /' .

How can I save the file as it is written in the textbox?

Here is a source code of the main file:

<form id="form1" name="form1" method="post" action="write.php">
<?php

$lines = file('content.htm');

$html = implode('', file('content.htm'));

echo' <textarea name="contents" cols="80" rows="40" wrap="off">' .$html. '
</textarea> ' ;
?>


And the file (write.php) which writes to the .htm file:

<?php
$content = $_POST['contents'];
$File = "content.htm";
$a = htmlentities($content);

$b = html_entity_decode($a);

$Handle = fopen($File, 'w');


fwrite($Handle, $b);
fclose($Handle);

?>

Thank You!  ;D
Link to comment
https://forums.phpfreaks.com/topic/30916-i-need-help-with-this-small-code/
Share on other sites

[code]
<form method="post">
<?php
  $lines = file('content.htm');
  $html = implode('', file('content.htm'));
  echo' <textarea name="contents" cols="80" rows="40" wrap="off">' .$html. '</textarea> ' ;
?>
<input type="submit">
<?php
  if (isset($_POST['submit'])) {
    $content = stripslashes($_POST['contents']);
    $File = "content.htm";
    $a = htmlentities($content);
    $b = html_entity_decode($a);
    $Handle = fopen($File, 'w');
    fwrite($Handle, $b);
    fclose($Handle);
  }
?>
[/code]

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.