GIDForums  

Go Back   GIDForums > Computer Programming Forums > MySQL / PHP Forum
User Name
Password
Register FAQ Members List Calendar Search Today's Posts Mark Forums Read

 
 
Thread Tools Search this Thread Rate Thread
  #1  
Old 14-Jan-2005, 13:56
dopee dopee is offline
Awaiting Email Confirmation
 
Join Date: Feb 2004
Location: south africa
Posts: 109
dopee will become famous soon enough

saving html text


I'm trying to save html text to a file after being retrieved through a form.
So a textarea displays html text, which is sent via post and stored in a variable. The html file is then deleted and a new one is made with the new edited html text. What happens with my code is that when you edit the html text in the textarea, it doesn't seem to be saving.
Here's my code:

PHP Code:

<?
function displaytext($pathfile)
{
 echo "Editing page: <b>$pathfile</b><br /><br />\n";
 echo '<form action="temp1.php" method="post">';
 echo "<input type=\"hidden\" name=\"stage\" value=\"2\">";
 echo "<input type=\"hidden\" name=\"whichpage\" value=\"".strtolower($pathfile)."\">";
 echo '<textarea name="editedtext" cols="60" rows="6">';
    include_once($pathfile);
 echo '</textarea><br><br><input type="submit" value="save"></form>';
}

function savetext($htmltext,$pagename)
{
 if (file_exists($pagename))
 unlink($pagename);
 else echo "Error: Page $pagename not found.";
 $filepointer = fopen($pagename,"w+");
 fputs($filepointer, $htmltext);
 fclose($filepointer);
 echo "$pagename saved succesfully.<br><a href=\"temp1.php\">Home</a>";
}

if (empty($stage)) $stage = 1;
switch ($stage)
{
 case 1:
 displaytext("temp1.html");
 break;
 case 2:
 savetext($editedtext,"temp1.html");
 break;
}
?>


What seems to be the problem? The html text seems to be sent and saved correctly, becuase the file is deleted and then saved. But the html text saved is exactly what the original text was.
www.sportstar.co.za to view this script in action. Try edit the html text and save, then reload the script and see what happens.
I'm lost pls can someone help me
peace, Rich
  #2  
Old 17-Jan-2005, 04:15
dopee dopee is offline
Awaiting Email Confirmation
 
Join Date: Feb 2004
Location: south africa
Posts: 109
dopee will become famous soon enough
doh!!!
I forgot to change file permissions for temp1.html
It works fine now...www.sportstar.co.za
silly me
I don't understand why the server didn't give an write to file error, doesn't matter now i guess.
 
 

Recent GIDBlogLast Week of IA Training by crystalattice

Thread Tools Search this Thread
Search this Thread:

Advanced Search
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 Off
HTML code is Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
burning problems PLEASE PLEASE HELP kelticeire Computer Hardware Forum 4 01-Dec-2006 15:39
working with html HELP dopee MySQL / PHP Forum 10 18-Jan-2005 04:31
converting text files to html files kensenb C Programming Language 13 09-Nov-2004 11:33
CD burner wont burn!! robertli55 Computer Hardware Forum 1 18-Jun-2004 10:53
Yet another CD burner problem: Lite-On LSC-24082K Erwin Computer Hardware Forum 1 22-May-2004 11:28

Network Sites: GIDNetwork · GIDWebHosts · GIDSearch · Learning Journal by J de Silva, The

All times are GMT -6. The time now is 04:24.


vBulletin, Copyright © 2000 - 2008, Jelsoft Enterprises Ltd.