L
LearningPHP

  • Nov 9, 2006
  • Joined Nov 8, 2006
  • Nope, I have no problem with slashes being introduced. So I haven't had to apply the stripslashes function anywhere.

    My problem is that I after posting the form, the page reloads but without including the (recently changed) target tile. Why?

    • Here is the script code you graciously shared.

      cahva wrote:
      <?php
      $filename = '../txt/grad.txt';
      $msg = '';
      
      if (isset($_POST['FCKeditor1'])) {
      	// took out the is_writable bcos the next check will fail if it isnt
      	if (!$handle = fopen($filename, 'w')) {
      		$msg = "Cannot open file ($filename)";
      	} else {
      		if (fwrite($handle, $_POST['FCKeditor1']) === TRUE) {
      			$msg = "Cannot write to file ($filename)";
      		} else {
      			$msg = 'Wrote syccesfully to file ('.$filename.')';
      			$content = $_POST['FCKeditor1'];
      			fclose($handle);
      		}
      	}
      }
      
      // If $content is not yet set and $filename exists, retrieve the contents of the file
      if (!isset($content) && file_exists($filename)) {
      	$content = file_get_contents($filename);
      } else {
      	$content = '';
      }
      
      include('../includes/header.php');
      include('../includes/sidebar.php');
      
      
      <td id="main_content">
        <span class="heading_text">TxTCmS Administration</span><br />    <br />
      <?php 
      // Print status message if there is any.
      if (!empty($msg)) {
      	echo '<strong>'.$msg.'</strong';
      }
      
      include("../FCKeditor/fckeditor.php"); ?>
      
      <form method="post" action"<?php echo $_SERVER['SCRIPT_NAME'];?>">
      
      <?php 
      $oFCKeditor = new FCKeditor('FCKeditor1') ;
      $oFCKeditor->BasePath = '../FCKeditor/';
      $oFCKeditor->Height = '350' ;
      $oFCKeditor->Value = $content;
      $oFCKeditor->Create() ;
      ?>
      
      <input type="submit" name="submit" value="Save Page"></input>
      </form></td>
      </table>
      
      <?php include('../includes/footer.php')?> 
      

      I made one or two corrections. And configured it for my FCK install/needs.

      However, the one thing it does not seem to do is reload $content. After making edits and posting the changes, the target $filename is modified. The page reloads itself, but this time $content is blank.

      Why? I had expected it to retrieve the $filename, in order to provide visual proof the edits occurred (in addition to the message line that gets inserted).

      Indeed the code has a line to check if $filename exists and, if so, load it as $content. Yet, it does not.

      Thanks for any help on this point.