SunQuest
           PHP Coding
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Codewalkers ForumsPHP RelatedPHP Coding

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Codewalkers Forums Sponsor:
Be the architects of evolution and help create the mobile internet future. It’s your move---enter to win here!
  #1  
Old September 12th, 2002, 10:30 PM
mojo mojo is offline
Codewalkers Newbie (0 - 499 posts)
 
Join Date: Apr 2007
Location: United States
Posts: 4 mojo User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
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)

Reply With Quote
  #2  
Old September 13th, 2002, 04:09 PM
zombie zombie is offline
Codewalkers Intermediate (1500 - 1999 posts)
 
Join Date: Apr 2007
Location: serbia
Posts: 1,876 zombie User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 3
RE: updating a html file with php... i'm stuck, please help

this is about permisions for shure...

to see the err, try setting error_reporting() to E_ALL

Reply With Quote
  #3  
Old September 16th, 2002, 11:32 AM
mojo mojo is offline
Codewalkers Newbie (0 - 499 posts)
 
Join Date: Apr 2007
Location: United States
Posts: 4 mojo User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
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.)


Reply With Quote
  #4  
Old September 17th, 2002, 01:59 PM
mojo mojo is offline
Codewalkers Newbie (0 - 499 posts)
 
Join Date: Apr 2007
Location: United States
Posts: 4 mojo User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
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!

Reply With Quote
  #5  
Old September 18th, 2002, 12:25 AM
Anonymous Anonymous is offline
Registered User
Codewalkers God 35th Plane (22000 - 22499 posts)
 
Join Date: Apr 2007
Posts: 22,309 Anonymous User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 24
updating a html file with php... i'm stuck, please help

Not a problem

Reply With Quote
  #6  
Old September 18th, 2002, 12:28 AM
mojo mojo is offline
Codewalkers Newbie (0 - 499 posts)
 
Join Date: Apr 2007
Location: United States
Posts: 4 mojo User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
updating a html file with php... i'm stuck, please help

no problem (this login thing is goofy)

Reply With Quote
Reply

Viewing: Codewalkers ForumsPHP RelatedPHP Coding > updating a html file with php... i'm stuck, please help


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


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
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 5 hosted by Hostway