Hi..

When I have the debug mode on I don't get any error, but after clicking submit on form.php the page just goes blank.. but it's supposed to echo, any idea how I could fix it?

form.php:

<?php
error_reporting(2047); // debug 
	echo "<form id='form1' name='form1' method='post' action='edit.php'>Filename:<br>" 
				. "<input name='filename' type='text' id='filename' value='' />"
				. "<input name='subfilename' type='hidden' id='subfilename' value='1' />"
	   			. "<input type='submit' name='Submit' value='Submit' /></form>";
?>

edit.php:

<?php
error_reporting(2047); // debug 
$filename = $_POST['filename'];

class edit
{
	function edit(){

	 if(isset($_POST['subfilename'])){
     $this->procTextArea();
	 }
	 else if(isset($_POST['subeditfile'])){
     $this->procEditFile();
	 }
 }

function procTextArea(){

$file=fopen($filename, "r");
$read=fread($file, 900000);
		echo "Editing: <b>" . $filename . "</b><br>"
			. "<form id='form1' name='form1' method='post' action='edit.php'>"
			. "Edit:<br /><textarea name='edit' id='edit'>" . $read . "</textarea>"
			. "<input name='subeditfile' type='hidden' id='subeditfile' value='1' />"
   			. "<input type='submit' name='Submit' value='Submit' /></form>";
fclose($file);		
}


function procEditFile(){
	$edit = $_POST['edit'];
	$edit_file=fopen($filename, "w+");
	$file_read=fread($edit_file, 90000);	
		if (!$edit==$file_read && !$file_read==""){
			fwrite($edit_file, $edit);

		} else if (!$file_read==$edit){
			echo "Error,<br><br>" . $edit . "<br><br>Could not be written to " 
				. $filename;

		} else if ($file_read==$edit) {
			echo "Success,<br><br>" . $edit . "<br><br>has been written to " 
				. $filename;
		}
	fclose($edit_file);
	}		

};
?>

    Because the class is just loaded I don't know all about classes, but I do know you need to create an instance of it, but it is causing errors but make this change and then post the errors so those that understand classes more than I can help you with it.

    <?php
    error_reporting(2047); // debug
    $filename = $_POST['filename'];
    $test= new edit;
    $test->edit();
    class edit
    {
        function edit(){
    
         if(isset($_POST['subfilename'])){
         $this->procTextArea();
         }
         else if(isset($_POST['subeditfile'])){
         $this->procEditFile();
         }
     }
    function procTextArea(){
    $file=fopen($filename, "r");
    $read=fread($file, 900000);
            echo "Editing: <b>" . $filename . "</b><br>"
                . "<form id='form1' name='form1' method='post' action='edit.php'>"
                . "Edit:<br /><textarea name='edit' id='edit'>" . $read . "</textarea>"
                . "<input name='subeditfile' type='hidden' id='subeditfile' value='1' />"
                   . "<input type='submit' name='Submit' value='Submit' /></form>";
    fclose($file);        
    }
    function procEditFile(){
        $edit = $_POST['edit'];
        $edit_file=fopen($filename, "w+");
        $file_read=fread($edit_file, 90000);    
            if (!$edit==$file_read && !$file_read==""){
                fwrite($edit_file, $edit);
    
            } else if (!$file_read==$edit){
                echo "Error,<br><br>" . $edit . "<br><br>Could not be written to "
                    . $filename;
    
            } else if ($file_read==$edit) {
                echo "Success,<br><br>" . $edit . "<br><br>has been written to "
                    . $filename;
            }
        fclose($edit_file);
        }        
    
    };
    ?> 

      It worked (for the blank), but now it's echoing twice for procTextArea instead of just once.. I also had to make another hidden value (so I could define $filename in procEditFile).. But now it's echoing twice for procEditFile also, and it won't write to the file, it's displaying the error message, any idea why it's not working? I don't understand why it would read the file content's into the textarea, but not write to the file?

      <?php
      error_reporting(2047); // debug
      $test= new edit;
      $test->edit();
      class edit
      {
          function edit(){
      
           if(isset($_POST['subfilename'])){
           $this->procTextArea();
           }
           else if(isset($_POST['subeditfile'])){
           $this->procEditFile();
           }
       }
      function procTextArea(){
      $filename = $_POST['filename'];
      $file=fopen($filename, "r");
      $read=fread($file, 900000);
              echo "Editing: <b>" . $filename . "</b><br>"
                  . "<form id='form1' name='form1' method='post' action='edit.php'>"
                  . "Edit:<br /><textarea name='edit' id='edit'>" . $read . "</textarea>"
                  . "<input name='subeditfile' type='hidden' id='subeditfile' value='1' />"
      			. "<input name='filename' type='hidden' id='filename' value='" . $filename . "' />"
                     . "<input type='submit' name='Submit' value='Submit' /></form>";
      fclose($file);        
      }
      function procEditFile(){
          $filename = $_POST['filename'];
          $edit = $_POST['edit'];
          $edit_file=fopen($filename, "w+");
          $file_read=fread($edit_file, 90000);    
              if (!$edit==$file_read && !$file_read==""){
                  fwrite($edit_file, $edit);
      
              } else if (!$file_read==$edit){
                  echo "Error,<br><br>" . $edit . "<br><br>Could not be written to "
                      . $filename;
      
              } else if ($file_read==$edit) {
                  echo "Success,<br><br>" . $edit . "<br><br>has been written to "
                      . $filename;
              }
          fclose($edit_file);
          }        
      
      };
      ?> 
        Write a Reply...