Sesquipedalian Posted July 16, 2006 Share Posted July 16, 2006 Hi.. Well, I am trying to make something that you enter in the filename of a file you want to edit, then a textarea comes up with what's on that file, you edit it, then it edit's the file.. Well, it's not working, first off, for some reason it is echoing twice instead of once, and it won't edit the file correctly (I'm guessing because there are two different forms named the same thing)..[b]form.php[/b][code=php:0]<?phperror_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>";?>[/code][b]edit.php[/b][code=php:0]<?phperror_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>"; } 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); } };?> [/code] Quote Link to comment https://forums.phpfreaks.com/topic/14792-echoing-twice/ Share on other sites More sharing options...
cunoodle2 Posted July 17, 2006 Share Posted July 17, 2006 Sorry..just for a little clarification...What is your form doing?What are you EXPECTING it to do that it is not?I know that you said it was echoing twice but what is it echoing twice? Like a certain line in there?? Quote Link to comment https://forums.phpfreaks.com/topic/14792-echoing-twice/#findComment-59191 Share on other sites More sharing options...
Sesquipedalian Posted July 17, 2006 Author Share Posted July 17, 2006 Whenever I write echo it echo's twice. ;] I found out why though. Quote Link to comment https://forums.phpfreaks.com/topic/14792-echoing-twice/#findComment-59551 Share on other sites More sharing options...
redarrow Posted July 17, 2006 Share Posted July 17, 2006 is it becouse i's in the while loop somewere?tell us then cheers. Quote Link to comment https://forums.phpfreaks.com/topic/14792-echoing-twice/#findComment-59566 Share on other sites More sharing options...
Sesquipedalian Posted July 18, 2006 Author Share Posted July 18, 2006 [code=php:0]<?phperror_reporting(2047); // debug$test = new edit;$test->edit();class edit{ function edit(){[/code]If I remove[code=php:0]$test->edit();[/code]Then it only echo's once. Quote Link to comment https://forums.phpfreaks.com/topic/14792-echoing-twice/#findComment-59753 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.