A php notepad - preCharge Forums
It shows that you are unregistered. Please register with us by clicking Here
preCharge Forums


Nav Green LeftNav Right
preCharge Forums > Website Design & Development > Programming > PHP » A php notepad


Reply
Tcat Right
 
LinkBack Thread Tools Display Modes Tcat Right
Old 07-26-2006   #1 (permalink)
Anman
 
Posts: n/a
Default A php notepad

Im sure there are people here who like to code php. There has to be, because Im one of them.

Anyway, to my point. Im a very busy stressfull and mostly lazy man and I need a very simple php notepad to store notes on line. Sure, I could just use my forum, except I dont want to for miscelaneous reasons. Hell, I could do it, but right now I dont want to see any code untill I feel a little better.

Anyone up for it? Ill applaud them continously for the next week or so while I do my rounds.

And of course, Im not a greedy man, Im sure we could all share.
  Reply With Quote


Old 07-27-2006   #2 (permalink)
Jamie
Senior Member
 
Jamie's Avatar
 
Join Date: Jul 2006
Location: Swansea, Wales, UK
Age: 20
Posts: 239
Default Re: A php notepad

ok....this is entirly untested since im writing it as i go along....

Code:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="english">
<head>
<title>Jamie Lewis - Notepad</title>
<meta name="author" content="Jamie Lewis" />
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<link rel="stylesheet" type="text/css" href="main.css"/>
</head>
<body>
<?php
if(isset($_POST["notes"])){
 $file = fopen("note.txt",'w');
   if(fwrite($file,$_POST["notes"])){ 
    echo "File Written Successfully";
  }
fclose($file);
}

$file = fopen("note.txt",'r');
$content = fread($file,filesize("note.txt"));
echo "<form action='notes.php' method='post'>";
echo "<fieldset>";
echo "<legend>Notepad</legend>";
echo "<label for='notes'>Notes:</label><br/>";
echo "<textarea name='notes' id='notes' cols='50' rows='3'>".htmlentities($content)."</textarea>";
echo "<input type='submit' value='Save'/>";
echo "</fieldset>";
echo "</form>";

?>
</body>
</html>
Thats the very basics, it should work and I may test and update later on.

Jamie
__________________
Jamie is offline   Reply With Quote

Old 07-27-2006   #3 (permalink)
Anman
 
Posts: n/a
Default Re: A php notepad

You accidently put the html closing tags in the php tags.
  Reply With Quote

Old 07-27-2006   #4 (permalink)
Jamie
Senior Member
 
Jamie's Avatar
 
Join Date: Jul 2006
Location: Swansea, Wales, UK
Age: 20
Posts: 239
Default Re: A php notepad

Yeah, ive edited it now. Was typing pretty damn fast.

Jamie
__________________
Jamie is offline   Reply With Quote

Old 07-27-2006   #5 (permalink)
Anman
 
Posts: n/a
Default Re: A php notepad

You double quoted

if(isset($_POST[''notes"])){
  Reply With Quote

Old 07-27-2006   #6 (permalink)
omghaxzs
Junior Member
 
Join Date: Jul 2006
Age: 17
Posts: 17
Send a message via AIM to omghaxzs Send a message via MSN to omghaxzs
Default Re: A php notepad

Quote:
Originally Posted by Jamie
Code:
if(isset($_POST["notes"])){
 $file = fopen("note.txt",w);
   if(fwrite($file,$_POST["notes"])){ 
    echo "File Written Successfully";
just my opinion, but don't you think the fopen should be fopen("note.txt",a+);?

just so if he needs to store more notes in the same file it doesn't overwrite it because the file pointer starts at the end.
omghaxzs is offline   Reply With Quote

Old 07-27-2006   #7 (permalink)
Anman
 
Posts: n/a
Default Re: A php notepad

Oh and you have too many closing }

edit

and you forgot to add $comment inbetween ..
  Reply With Quote

Old 07-27-2006   #8 (permalink)
Jamie
Senior Member
 
Jamie's Avatar
 
Join Date: Jul 2006
Location: Swansea, Wales, UK
Age: 20
Posts: 239
Default Re: A php notepad

There we go its tested and it works. The reason i didnt append was because the entire file gets rewritten to help preserve edits etc. And for a script written in two minutes I dont think its half bad.

Jamie
__________________
Jamie is offline   Reply With Quote

Old 07-27-2006   #9 (permalink)
omghaxzs
Junior Member
 
Join Date: Jul 2006
Age: 17
Posts: 17
Send a message via AIM to omghaxzs Send a message via MSN to omghaxzs
Default Re: A php notepad

No he doesn't...he has two IF statements so he only needs two closing brackets.
omghaxzs is offline   Reply With Quote

Old 07-27-2006   #10 (permalink)
Anman
 
Posts: n/a
Default Re: A php notepad

Dude, its awsomeness.

Quote:
Originally Posted by omghaxzs
No he doesn't...he has two IF statements so he only needs two closing brackets.
He removed the other one. he had 3 before.


edit-
for your enjoyment.


Warning: fopen(note.txt): failed to open stream: Permission denied in /home/ankindus/public_html/anman/notes.php on line 12

Warning: fwrite(): supplied argument is not a valid stream resource in /home/ankindus/public_html/anman/notes.php on line 13

Warning: fclose(): supplied argument is not a valid stream resource in /home/ankindus/public_html/anman/notes.php on line 16

Warning: fread(): Length parameter must be greater than 0. in /home/ankindus/public_html/anman/notes.php on line 20

edit-

whoa.. forget that.. my ftp didnt save my cmod.

edit-

http://www.ankindustries.com/anman/notes.php

YEEHAW!!

edit-

Just editing for fun.
  Reply With Quote

Reply



Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


footer left
All times are GMT. The time now is 12:13 AM.

DISCLAIMER: preCharge Risk Management is not responsible for any opinions, advice or comments expressed on the preCharge Community Forums.
preCharge® is a registered trademark of preCharge Risk Management | chargeback protection | Merchant Account Blog

Powered by vBulletin
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO 3.0.0 RC6

Advertising | Mobile Phone deals | Myspace Proxy | Personal Loans | Charity

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49