Notepad PHP Script

amr1991

New Member
Messages
396
Reaction score
0
Points
0
I am trying to create a PHP script that will save the notes you typed in. Basically its a textarea and you can type in it and click save and it will remain everytime you come back unless you highlight it and press backspace then save. I am assuming to use a flatfile not a database for this.
 

t2t2t

New Member
Messages
690
Reaction score
0
Points
0
And...?

(Some more words here to make sure this post ain't too small)
 

amr1991

New Member
Messages
396
Reaction score
0
Points
0
I'm making a cms for my website, i want to make this so that I can save notes so other admins can see them later.
 

bigguy

Retired
Messages
10,984
Reaction score
10
Points
38
Did you need help with this in someway. ???

I am trying to create a PHP script that will save the notes you typed in. Basically its a textarea and you can type in it and click save and it will remain everytime you come back unless you highlight it and press backspace then save. I am assuming to use a flatfile not a database for this.
 

Brandon

Former Senior Account Rep
Community Support
Messages
19,181
Reaction score
28
Points
48
Are you trying to make a box that people (admins you mean) can type into, click save and all the other admins can view it???
 

amr1991

New Member
Messages
396
Reaction score
0
Points
0
^ Exactly what brandon said :D Just like in IPB's backend.
 

Brandon

Former Senior Account Rep
Community Support
Messages
19,181
Reaction score
28
Points
48
Make a text box.

Then make a "submit" button. Make a file and make it update the file when you click submit and read a file when you open the page/

Like that;)

btw Moving to Tech Intetwaz or w/e it is.
 
Last edited:

Torch

New Member
Messages
634
Reaction score
0
Points
0
I think this is basically what you wanted:
PHP:
<?
$notesfile = "notes.txt";
if(isset($_POST['save'])){
   $file = fopen($notesfile,"w+");
   fwrite($file, stripslashes($_POST['contents']));
   fclose($file);
}
$contents = htmlspecialchars(file_get_contents($notesfile));
$changetime = date("jS M Y, H:m:s",filemtime($notesfile));
echo <<<HTML
<html>
<head>
<title>Notes and such</title>
<body>
<form action="{$_SERVER['PHP_SELF']}" method="post">
<textarea rows=30 cols=80 name="contents">$contents</textarea><br />
<input type="submit" name="save" value="Save notes" />&nbsp;&nbsp;Last time changed: <b>$changetime</b>
</form>
</body>
</html>
HTML;
?>

You can just edit the html inside the "echo <<<HTML" and "HTML;", and change the way it looks so that it blends with your site. Also, you need to have file named "notes.txt" in same folder as this script. That is where the notes will be saved. If you with to have that file somewhere else or named differently, just change $notesfile var to your path.
 
Last edited:

amr1991

New Member
Messages
396
Reaction score
0
Points
0
thank you for the script torch, and everyone elses help :biggrin:
 

Origin

New Member
Messages
1,082
Reaction score
0
Points
0
You're gonna make a CMS and you don't know how to do this? O_O
 
Top