I posted both pieces of code here:
http://pastebin.com/nPa4x5tP
It should be pretty obvious what I'm trying to do. I found this example online of a form that was able to edit a text file, but it doesn't work (I absolutely *hate* when people submit examples that do not work, and yes, hate is a strong word). Sometimes I realize I may not be doing something right, and that's why it doesn't work.. but I'm stumped on this one, and I seem to be using fwrite() correctly, although I can't find a specific example online using $_POST.
At first it was giving me an error saying fwrite expected a string, but a resource was given. After playing around with it, now it doesn't return any errors. What am I doing wrong??
I've created the file and it's in the same directory as these files (data.txt).
It appears to work, but then doesn't replace what is currently in the file with the $_POST data being submitted. I'm sure it's something simple.. but it's driving me nuts and I cannot figure it out.
I figured maybe it was replacing what's in the file, with what's already in the file.. but the post data should contain whatever is being submitted in the form.
Can someone please correct this for me, or tell me how?
Thanks
Edit: Here's the original place I got the example. I just looked at it again, and can't find anything in it that I changed to make it not work, or anything like that. It just didn't seem to right off-the-bat, but maybe you guys will have a little better luck:
http://phpsnips.com/21/Edit-And-Save-A-File#.U65zm7GU93l
http://pastebin.com/nPa4x5tP
It should be pretty obvious what I'm trying to do. I found this example online of a form that was able to edit a text file, but it doesn't work (I absolutely *hate* when people submit examples that do not work, and yes, hate is a strong word). Sometimes I realize I may not be doing something right, and that's why it doesn't work.. but I'm stumped on this one, and I seem to be using fwrite() correctly, although I can't find a specific example online using $_POST.
At first it was giving me an error saying fwrite expected a string, but a resource was given. After playing around with it, now it doesn't return any errors. What am I doing wrong??
I've created the file and it's in the same directory as these files (data.txt).
It appears to work, but then doesn't replace what is currently in the file with the $_POST data being submitted. I'm sure it's something simple.. but it's driving me nuts and I cannot figure it out.
I figured maybe it was replacing what's in the file, with what's already in the file.. but the post data should contain whatever is being submitted in the form.
Can someone please correct this for me, or tell me how?
Thanks
Edit: Here's the original place I got the example. I just looked at it again, and can't find anything in it that I changed to make it not work, or anything like that. It just didn't seem to right off-the-bat, but maybe you guys will have a little better luck:
http://phpsnips.com/21/Edit-And-Save-A-File#.U65zm7GU93l
Last edited: