matak
May 25 2007, 06:04 AM
I made a simple flat file text editor, that can show you probably how simple it is to use forms with php and write that data to file. This example has 2 files, submit.php, and postit.html. Submit.php is used to write title, and some text, and add html tags, and paragraph tags where new paragraphs are. Here's the file with comments. I think that HTML really doesn't need some more explaining. CODE Title: <br /> <input type="text" name="title" size="53"> <br /> Text: <br /> <textarea name="text" rows="20" cols="40"></textarea><br /> <br /> <input type="submit" value="Save"> </form> <?php if (@$_POST['title']=="" || @$_POST['text']==""){ echo "Enter text to save!"; } else { //this is path to file $filename = './postit.html'; //i used $title to strip HTML/PHP tags < >, and added <h2> HTML tag to decorate title $title = "<h2>".strip_tags($_POST['title'])."</h2>\n"; //with this $_POST['text'] is stripped from html/php tags like title, but also preg_replace //is used to replace \n(every enter that u hit when writing tekst), //and instead of that added <p> tags which decorate your new paragraph $tekstmanage = preg_replace('/\n/','</p><p>', strip_tags($_POST['text'])); //i should probably write a whole preg_replace function instead, which i will probably later, //but this $tekst variable is used to add finishing and closing tags //to our tekst manage. you can see how preg_replace adds first closing than starting tags //and with this we just simply add starting before closing and closing after starting tags :confused:;) $tekst = "<p>".$tekstmanage."</p>\n"; //after our variables are defined, we combine them in unique variable which we'll write to file $content = $title.$tekst; //This below is basic write to file function that i found on php.net, and rearanged //i'll just explain it briefly // //this checks weather our filename is writeable (on unix systems like here on trap17) //you need to change permissions to the file that allows writing to world 646 if (is_writeable($filename)){ //if file cant be opened to add -> 'a' <- in the fopen construct //just echo sorry if(!$handle= fopen($filename,'a')){ echo "Sorry, you can't write to file1"; } //if file cant be written to, same if (fwrite($handle, $content) === FALSE){ echo "Sorry, you can't write to file2"; exit; } //if both of those terms are fine just echo the confirmation text echo "You wrote to file ".$filename."<br />"; echo "<a href=\"postit.html\">View</a>"; } //if file isn't writeable else { echo "Sorry, you can't write to file3"; } } ?> Well, there it is, hope u have fun with it. Also this needs a bit more work to be done with it, so i won't post dl link. If you have any questions about the script, you know what to do EDIT: Note to moderators, sorry this is not a real text EDITOR (it only writes), so can u please edit the title, to suit the script better.. Thanks 
Reply
Blessed
May 25 2007, 09:05 AM
Greetings man thanx for the script it simple and short. but what is the extention of the file when you save it ??? ..........
Reply
matak
May 25 2007, 12:02 PM
QUOTE(Blessed @ May 25 2007, 11:05 AM)  Greetings man thanx for the script it simple and short.
but what is the extention of the file when you save it ???
.......... file extension, and path is given with this variable CODE $filename = './postit.html'; ./ means to look in the current directory, and filename's extension is .html. You can change extension to any one you like just my renaming the file that PHP looks for  . This script doesn't create file if it doesn't egzist, it just writes to egzisting file, so make sure to create file you will be writing to before running script. Yes, it's short, but i posted it mostly for that preg_replace thing, although i admit it needs some more work, so that it writes nicer code than it does now. And soon i'll create a bit more powerfull, but again, simple, text editor (script that reads files, and allows you to edit them), but that needs a bit more work, and probably use of file_get_contents function. I'll look into it when i have more time  EDIT: Thank you jlhaslip for changing the title, manipulator, sounds nice 
Reply
Blessed
May 25 2007, 12:25 PM
QUOTE(matak @ May 25 2007, 12:02 PM)  file extension, and path is given with this variable CODE $filename = './postit.html'; ./ means to look in the current directory, and filename's extension is .html. You can change extension to any one you like just my renaming the file that PHP looks for  . This script doesn't create file if it doesn't egzist, it just writes to egzisting file, so make sure to create file you will be writing to before running script. Yes, it's short, but i posted it mostly for that preg_replace thing, although i admit it needs some more work, so that it writes nicer code than it does now. And soon i'll create a bit more powerfull, but again, simple, text editor (script that reads files, and allows you to edit them), but that needs a bit more work, and probably use of file_get_contents function. I'll look into it when i have more time  EDIT: Thank you jlhaslip for changing the title, manipulator, sounds nice  Greetings Thanx man for the quick repply i'm looking forward to use this script and see it in action  thanx, have a nice day
Reply
Similar Topics
Keywords : , php, simple, flat, file, text, manipulator, forms, write, files, php
- How Can You Get Audio Files From Itunes Videos?
(1)
Making A Simple Signature With Adobe Photoshop
A tutorial to basic signature designing: By Accure (3) Specs Hardness: 4 / 10 Time: about 10 minutes Result: My .PSD File: Download it now!
Needings: -Basic Photoshop knowlegend. -Adobe Photoshop CS2 (Or CS3/CS4) -Brushes set ( available
here ) -A render ( available here ) Basic knowlegend: Steps: 01. Open Adobe Photoshop,
and go File > New. 02. select the sizes Width: 350 pixels . Height: 150 pixels . Press OK .
03. Press the button to maximize the window of your new project. 04. Fill your background with
black (by using the "fill" function). 05. Press F5, click on the small arrow a....
Naming Web Page Files
Which way you like- MyPage.html or my-page.html or my_page.html (7) Everybody talks about meta tags, keywords, good title names and how they can increase page rankings,
etc. But I was wondering whether the page name itself holds any value in indexing. Yes, I am
talking about the web page file names (some-thing.html) NOT the one which you put in title tags. I
am going to express my views and want to know what you think is correct. I have seen pages named in
various ways like these: 1) my_web_page.html 2) DoYouLikeMyPage.html 3) hey-see-my-webpage.html (I
think this way is more appropriate) 4) this.is.a.page.html (somewhat confusing) ....
Audio Files?
(3) I need some help. Is it possible to get audio files off of sites? Like IMEEM and YouTube. I know the
whole http://www.file2hd.com thing. It doesn't always work though. Are there other ways? Is
there a way people hack audio files off of sites? NOTE: I DO NOT WANT DO THIS! I merely want to
know so that I can protect my sites from it. Thanks.....
Jar Executable Files
(1) I have been supplied with a digital log book for use this semester and it comes in the form of a
.jar file and a .mdb file. I tried running it on my mac but it crashes every time but it seems to
run perfectly on windows xp. Does anyone have any ideas why? I thought .jar files would be
computable on any platform. ....
Internal File Transfer
(5) Is there some kind of file transfer utility that can be used within the intranet for file
transfers..? We have so much need for such an utility here in my work place.... The problem with
what we are using is very big... we are basically using skype in my workplace and the problem with
that is it happens with the internet... So whenever i transfer files via skype it occupies the
bandwidth.... which is very bad since we have a limited bandwidth connection. So... What i require
is a utility where the transfer happens within the network and not via the internet. So... if ....
Text Editors Vs Word Processors
(1) There are many differences between text editor and a word processor. One of those differences is
that most text editors are universal in editing any text based documents, while word processors can
only edit certain types of files like Open Office. So, because of that universal editing more text
editors are very basic and so they carry few commands, such as copy and paste and being able to save
the document. While word processors have hundreds of commands and come with many other features
such as templates, thesaurus, spell checker etc etc. So with all those features....
Best Way To Transfer Files
I just bought a laptop (6) Hi there guys, I just bought a brand new Dell Inspiron laptop for $729.99. It has a
processing speed of 2.0ghz, 3GB RAM, and a 250gb hard drive. I'm really satisfied, especially
with the wireless internet and the fact that I can carry my computer around with me, allowing you to
use your computer in comfortable spots -- outside in the shade, on the train, or even in your bed
where I'm using it write now as I type. If you didn't already guess, this is my first
laptop. But I do have some issues. Does anyone happen to know an easy way to transfer some ....
Weird Write Problem
(3) Any ideas whats up with this error? It just started appearing now. ....
1350 Great Free Logos (jpg + Psd)
With both jpg and original psd files to edit (7) 1350 Great Free Logos (With both jpg and psd files)
http://rapidshare.com/files/126291346/1346...Great.Logos.zip This is a great collection of
logos, they are already made logos which you can use like that or just use to create other logos, do
what you want, they are free, they came from free websites that give this logos for free and lot
more, but i just took the good ones mainly. There is also a small collection of 100 logos inside
the compressed file, which you can use to insert those graphics in your logo/design/web design
projects, do what you want with them ....
Free Software For File Recovery
RECUVA (3) Hi all, I was loking for a software to recover my lost files and I found this /biggrin.gif"
style="vertical-align:middle" emoid=":D" border="0" alt="biggrin.gif" /> And the best part is ,
its free Recuva - File Recovery Recuva (pronounced "recover") is a freeware Windows utility to
restore files that have been accidentally deleted from your computer. This includes files emptied
from the Recycle bin as well as images and other files that have been deleted by user error from
digital camera memory cards or MP3 players. It will even bring back files that have been d....
Text Based Rpg Game Maker
(3) Well I need one, if you can help please do...I would like it so I can have people play online.....
Converting Audio Files In Vista
how do you do it? (7) Ok, so I have some .wav files that I'd like converted into .mp3. I knew how to do it in XP, but
I can't find windows audio converter in Vista....does vista even have that, or is it under a new
name? Also, is it possible to convert video files, like .flv into .avi?....
Make A Flat Based Shoutbox, With Auto Refresh.
(6) With this tutorial, you will learn how to create a simple shoutbox, but only uses a .txt file. Also
with auto refresh, and I am going to do a backgound. We will be making 5 files. 1. index.php The
main page 2. msg.php Reading msg.txt 3. msg.txt Note: You must give it 777 4. shout.php Where
it add to msg.txt 5. bg.gif Background. Index.php would be like this: Shoutbox
Name: Message: Let's go over what the code do. -> are just the title.
gets msg.php which gets msg.txt. You will know why I do that later. -> is wh....
How To Use Command Prompt As A Text Editor
(6) In this tutorial, I will show you how you can use Command Prompt to create text files. It is very
simple and you can also use it to write output from a command into a text file. This can be
particularly useful when you need documentation from a DOS program in a text file when you use the
help command or something similar. In order to do this you simply use this DOS command. echo
Text >> test.txt This will create a new text file called test and echo the contents into it. If
we wanted to write a 2 line document, we could do something like: echo Hello >> test.txt e....
How To Write And Deliver A Good Short Speech
(1) The key to a good speech is to make it brief and straight to the point. If you do not take the time
to craft a tight, focused presentation for a short talk, you will lose your audience and possibly,
your reputation. A common misconception is that one does not need to practise a five-minute talk
because it is just a short speech, but this is the wrong mentality. Here are some guidelines on how
to write a good, short speech: 1. The writing for short speeches has to be better than for long
ones. You have less time to get your critical message across. 2. You must make sure....
What Program Do You Use To Design Your Web?
Frontpage, Dreamweaver, a good text editor? (82) I personaly choose frontpage because its easy to use but.....I use dreamweaver for PHP.....
How To Disable "show Hidden Files And Folders" In Folder Option
(11) How to disable "Show hidden files and folders" in Folder Option As you know, you can hide files
or folders in Microsoft Windows ( to hide a file or folder , right click on file or folder >select
properties and then select Hide file) But if you open Folder Option and check "Show hidden files
and folders " you can see hidden files. to disable "Show hidden files and folders" feature follow
below steps : 1- Click start > Run > type regedit to run Windows Registry Editor. 2- Go to following
address: QUOTE HKEY_LOCAL_MACHINE/SOFTWARE/Microsoft/Windows/Current Versio....
Qupis : Free Hosting With Php, Mysql, Cpanel. (one Line Text Ad At Bottom)
a member of Xisto (41) Hello Members, We are proud to introduce a new member to Xisto group of sites.
Qupis : Free Web Hosting 150 MB space, 5000 MB Bandwidth, php,
mysql, CPanel (Latest). Emails, FTP, Addon domains, Parked Domains etc.
http://www.Qupis.com
Feel free to add your reviews and comments about it. -Trap17
Management ....
Informix To Sql Server (or How To Open .unl Files)
how to import .unl files into SQL Server 2000 without Informix softwar (2) Does anyone know how to import .unl files into SQLServer 2000? My boss gave me this task to migrate
an old database into SQLServer. I don't have informix installed since the files were sent to me
via email. All files have .unl extension and I don't have a clue how to view them. I've
tried opening them using excel but it can't be read. Does anyone know how to do this? Or at
least know how to open/view the file using excel or any other program that could be easily migrated
to sqlserver? Please, I need to migrate the files as soon as possible. Thanks....
Read File (.txt) On Another Website Using Jsp?
(3) in my jsp program,i need to read a file (.txt) on another website,how can i do this? thanks a lot.
shorten title ....
A Trap17 How-to Guide For Beginners
Something for those who can't get enough of the Trap17 Readme file (12) I am not entirely sure if this the right place to post about this, but here goes anyway... For
those who find themselves slightly (or considerably more than slightly) clueless about where to get
started after getting a hosting account, here is an user guide that might potentially help you
out. I wrote it out of three hours, so forgive me if it's clumsy, but I'm hoping that a few
people here may find it useful. Feedback is greatly appreciated /smile.gif"
style="vertical-align:middle" emoid=":)" border="0" alt="smile.gif" /> I'm planning to build on
a FAQ....
How To Open A .daa File
(37) Hi there, How do i have to open a file with extension .daa Somebody told me to copy it on cd and to
run it from cd rom but i got the same problems. What dp i need to do to ppen the file? Thanks....
Watermark Your Image With Simple Php Script
found it on the net (34) This script was found on the net http://tips-scripts.com/?tip=watermark#tip B&T's Tips &
Scripts site. Just in case the site may not show, I will include the code here: List of things
needed: 1. your image in any format 2. watermark image--in gif format with transparent background 3.
script below with name (i.e. watermark.php) CODE <?php // this script creates a watermarked
image from an image file - can be a .jpg .gif or .png file // where watermark.gif is a mostly
transparent gif image with the watermark - goes in the same directory as this script // ....
Simple C File Handling In Action
Small code snipet which covers most of basic file handling and navigat (3) Yesterday I suddenly got a lot of work. The same work we try to push off, yes you are right all
formalities to get the code review incorporated and update all source code files with code review
headers. Imagine if you need to open 300 files one by one and append code review headers at the
end. Since most files are reviewed in groups of 20 to 30 files. We require one header to be placed
in say 20 to 30 files. To simplify I went back to my class assignment days and wrote this small c
utility to open all files passed on command line and open attach code review headers an....
Rap Lyrics
Can somebody write me some? plz..! (11) Ok I need someone to write me some rap lyrics. Basically what I want to say in the song is that i
love you, do you believe in destiny, that we'll be together, and kind of saying I'm not good
enough for you, you'll never be mine. Really hope someone can write me something with these
messages in. No not exactly like that but you know.. as I'm going to give it someone special to
me. Thanks.. /sad.gif' border='0' style='vertical-align:middle' alt='sad.gif' /> /ph34r.gif'
border='0' style='vertical-align:middle' alt='ph34r.gif' /> Oh I forgot.. Please....
Simple Sig Tutorial
photoshop sig tutorial : New to photoshop? (24) Mytutorial which i made for people who are new in photoshop: This is my first tutorial so maybe
there are few mistakes .......
The Best And Free Website/html Editors + Text Editors
A good collection! Check it out. (48) Here they are, the best html editors. Just pick one because they are all free, or choose one of the
ones i most recommend. WebCore Designer 2005 http://www.mpsoftware.dk/webcoredesigner.php
HTMLGate Free http://www.mpsoftware.dk/htmlgate.php Ma Page Web http://www.aldweb.com
MAX's HTML Beauty++ 2004 http://www.htmlbeauty.com WebWorks http://w1.213.telia.com
PageBuilder HTML Editor http://www.tafweb.com Website Mentor http://www.dark-street.com
Cascade DTP http://www.price-media.demon.co.uk BPlainPro http://home5.swipnet.se/~w-52253/hy....
Php Mod Rewrite Tutorial
Simple tutorial (3) REQUIRED: Internet server (Apache 1.3.33 recomended), php, basic skills with .htaccess Mod
rewrite is cool Apache option, it helps you to make your site URLs simple and clean... also it is
perfect for search engines... This is mod rewrite, it replaces : CODE
site.com/index.php?include=files?ID=45 with: CODE site.com/files/45 so lets get startet,
open notepad, enter this in it: CODE RewriteEngine On // - you are starting rewrite mod
:) RewriteBase / // - you set the rewrite base RewriteRule
^(.+)/([0-9]+)/?$ in....
Converting Video Files From One Format To Another
help plz :) (6) hey i have learnt this nice way to open mov files in imageready and insert them in sigs,graphics and
other stuff its really cool,this only works with .mov files and i really need to know if sumone here
can do that,i need to change a wmv file into a .mov file so i cant add the movie to a sig,i have
tried many video format conversion programs but they dont accept the mov format,the mov format is a
quicktime video format,so anyone here know how to change a video file into a quicktime mov video
format? thnx in advance....
Looking for , php, simple, flat, file, text, manipulator, forms, write, files, php
|
|
Searching Video's for , php, simple, flat, file, text, manipulator, forms, write, files, php
|
advertisement
|
|