|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
Be the architects of evolution and help create the mobile internet future. It’s your move---enter to win here! |
|
#1
|
|||
|
|||
|
updating a html file with php... i'm stuck, please help
Ok here's what i've been trying to accomplish. I want to call on a script somewhere on my website, in that script there is a textarea box with the code for a html file. I can then edit that code and click a submit button, which will then update the HTML file. I want this so i can easily update a page.
I've been asking around in other places and someone gave me a script to try, but i'm having trouble running that script. The script runs fine on my apache webserver on my Windows XP, but on my Linux computer, the file never updates, the code in the html file remains the same as before. This is either due to bad coding or file permissions, i honestly don't know. If someone could take a look at this, or even try this script on a webserver running Linux, i'd really appreciate it! (Or if you have a better script to accomplish this, let me know!) Update.php <? $myHTMLFile = "test.html"; $myHTML = implode( file( $myHTMLFile ), "" ); if ( $save ) { $tmpfile = fopen( $myHTMLFile, "w" ); $fp = fwrite( $tmpfile, $myHTMLText ); fclose($tmpfile); } ?> <html> <head> <title>Update.php</title> </head> <body> <div align=center> <form action="update.php"> <textarea name="myHTMLText" rows=35 cols=70><? echo $myHTML ?></textarea> <br> <input type="submit" name=save value=save> </form> </div> </body> </html> Thanks, (sorry for long post) |
|
#2
|
|||
|
|||
|
RE: updating a html file with php... i'm stuck, please help
|
|
#3
|
|||
|
|||
|
All wrapped up
Ok here's an update...
One of the problems was file permissions. Each file that i wanted to edit with the php script needed to be chmoded to 666 (or 777 so i'm told, but 666 worked fine for me). And... there were problems with the original code as well. I posted this message somewhere else and someone fixed up some parts of the code. I tried it last night and it worked great on my Apache. Thanks for taking a look at the code and tellin me what you think. (if anyone's interested in the modified code that was fixed, let me know and i'll post it.) |
|
#4
|
|||
|
|||
|
updating a html file with php... i'm stuck, please help
PHP:
<? if(isset($_POST[save])) { $data = "test.html"; $file = fopen("$data", "w"); $html = stripslashes($_POST[html]); fputs($file, $html); fclose($file); header("location: updated.html"); } ?> <html> <head> <title>Update.php</title> </head> <body> <div align=center> <form action="<?=$PHP_SELF?>" method="post"> <textarea name="html" rows=35 cols=70><? require("test.html"); ?></textarea> <br> <input type="submit" name=save value=save> </form> </div> </body> </html> Worked fine for me, enjoy! |
|
#5
|
|||
|
|||
|
updating a html file with php... i'm stuck, please help
Not a problem
|
|
#6
|
|||
|
|||
|
updating a html file with php... i'm stuck, please help
no problem (this login thing is goofy)
|
![]() |
| Viewing: Codewalkers Forums > PHP Related > PHP Coding > updating a html file with php... i'm stuck, please help |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|
|
|
|