473,770 Members | 1,880 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

PHP read and write txt file with html form

164 New Member
Hey guys, I assume there is a way to do this and it shouldnt be too difficult. I am just having a heck of time finding out how to do exactly this...

I have a flash file that is pulling text dynamically from a .txt file. I was wondering if how to make a form with a text area that will populate automatically from what is currently in the txt file. Then I could edit the data from there, submit it and it will all be updated.

I realize all of this could be done with a database but I will be doing more of these scenarios in the near future and thought this may be a lot quicker than setting up a database for each site.

So any help would be MORE than appreciated. Thank you!
Jan 24 '08 #1
4 11438
MarkoKlacar
296 Recognized Expert Contributor
Hi,

Start by looking at this function. What you're describing can be done, it's just a matter of figuring out the most difficult way of doing it (no sh*t).

The link should get you started I hope, write back if you need more help...

MK
Jan 24 '08 #2
mbatestblrock
164 New Member
Hi,

Start by looking at this function. What you're describing can be done, it's just a matter of figuring out the most difficult way of doing it (no sh*t).

The link should get you started I hope, write back if you need more help...

MK

Awesome I got it working!

Form page.

[PHP]<form action="process script.php" method="post">
<textarea rows="25" cols="40" name="content">
<?php
$fn = "test.txt";
print htmlspecialchar s(implode("",fi le($fn)));
?>
</textarea>
<br>
<input type="submit" value="Change!" >
</form>[/PHP]


and script page:

[PHP]<?php
$fn = "test.txt";
$content = stripslashes($_ POST['content']);
$fp = fopen($fn,"w") or die ("Error opening file in write mode!");
fputs($fp,$cont ent);
fclose($fp) or die ("Error closing file!");
echo "<meta http-equiv=\"refresh \" content=\"0; url=form.php\" />\n";
?>[/PHP]


Thanks a ton for the help, I knew it was a no brainer and I was just being dumb.
Jan 24 '08 #3
MarkoKlacar
296 Recognized Expert Contributor
Hey,

Don't call you self dumb think of it as obtaining knowledge.

MK
Jan 28 '08 #4
mbatestblrock
164 New Member
Hey,

Don't call you self dumb think of it as obtaining knowledge.

MK

NICE CALL on that one!
Jan 28 '08 #5

Sign in to post your reply or Sign up for a free account.

Similar topics

1
7132
by: jajoo | last post by:
Hi everyone, I am trying to send files with multipart/form-date. Everything is ok with the send. But when I am receiving the files I should specify a directory where the files to be saved. The problem is that Tomcat saves the files into %CATALINA_HOME%/bin directory. I am wondering why? Why not into my application directory? The application directory is %CATALINA_HOME%/webapps/picture. As a parameter of directory I am giving "." – which...
7
2990
by: Randell D. | last post by:
Whats wrong with my sample script below? All I want to do is confirm that my form data is in my environment (basically, I'm writing a script that will check that some form fields have a value, and others don't - The functionality of this will be used in my other script but I want to make sure I know whats happening first as opposed to bastardizing someone else's work). I have worked some of the code out - I figured the what should be...
7
7646
by: Nik Coughin | last post by:
Is there a simple way of opening a text file from a server, and reading from it line by line? IE http://someserver/file.txt contains a couple of hundred lines. Each line is the name of a file. I want to read this list of files into an array of strings. I don't have any control over the creation of file.txt so I really need to be able to read from it in it's existing format, a list of files seperated by carriage returns.
1
4310
by: Magix | last post by:
Hi, I have these string data: str_data1, str_data2, str_data3, which capture some value after a routine process A. Then I would like to write (append) these 3 string values into a text file each time after routine process A, the text file is named "mytext.dat" in following format with "#####" as separator. The maximum entries of them is 5. When reaching the fifth entry, it will delete the very first entry.
3
35008
by: Testguy | last post by:
Hi, I have been reading various messages in this group, and could not find an answer regarding what I am trying to do. At least, I could not find an easy answer. I am trying to figure out how to read and XML file and put the data in fields in a VB application, and also how to write the information to an XML file (either to a new file or modifying an existing file.
6
9691
by: Karthik | last post by:
I am trying to read Http request body values NOT form values The content type is text/xml and its POST I am posting data from Infopath to an asp.net page. In ASP it works by just writing Response.Write(request) the same does not work in ASP.NET I tried using Rquest.BinaryrRead() and Request.InputStream but it gives me text values as space separated (eg Karthik yyyy aaaa) whereas the data i am looking out for is in XML format.
5
5118
by: Sumana | last post by:
Hi All, We developed our project on VC++.Net console application to create image of disk and to write the image We are having problem with reading and writing the sector beyond 6GB Disk or Partition we are using ReadFile , WriteFile and setFilePointerEx to read and write the sectors and we are reading/writing 102400 sectors together, even we have reduced the sectors still it is not able to read or write, our program is working fine...
3
18961
by: nicolasg | last post by:
Hi, I'm trying to open a file (any file) in binary mode and save it inside a new text file. After that I want to read the source from the text file and save it back to the disk with its original form. The problem is tha the binary source that I extract from the text file seems to be diferent from the source I saved. Here is my code: 1) handle=file('image.gif','rb')
2
7701
by: Bina | last post by:
hi, I want to read & write a html file which contain the japanese character. Now how i will do it?I can read & write english character . but when i read & write Japanese character from the html file then the writed html file cannnot show the japanese character. my new created html file show the another character, it cannot show the original japanese character. But when i read & write data from a txt file it works. But only problem is,When...
0
9454
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
9904
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
8931
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
6710
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5354
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5482
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4007
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3609
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2849
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.