Jump to content

PHP Notepad Help Needed


Max Payne

Recommended Posts

I don't understand something with php.

I have this code:

<?php
if($_POST['content']){
$fff=fopen("notes.txt","w");
fwrite($fff, $_POST['content']);
}
?>
<form action='' method='POST'>
<textarea name='content' cols='90' rows='10'>
<?php
if (file_exists("notes.txt")) readfile("notes.txt");
?>
</textarea>
<br />
<input type='submit' value='Save Notes' class='inputbutton'> 
</form>

and i have the notes.txt file created, but each time i use the note pad in the code above, it always has to have a space or a character in it. It can't be blank. Why is this?

Edited by Max Payne
Link to comment
Share on other sites

Bumping is bad.

I see you're writing to notes.txt if youre POSTing content, and then reading it if it exists. How do you know it "doesnt work" with an empty file? Do you get an error, or are you putting something else into the IF to test it?

Why don't you always have the file there, and just see if it's empty or not?

Link to comment
Share on other sites

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now
×
×
  • Create New...