Multiple Step Function

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
palmere
Forum Newbie
Posts: 17
Joined: Fri Mar 19, 2004 5:33 pm

Multiple Step Function

Post by palmere »

I'm setting up an extremely simple CMS system that just writes to a text file on submission. The only problem is, if the update file is executed as it stands now, the $_POST['content'] variable is empty and it effectively deletes the content of the text file. Any Ideas?

Code: Select all

<?

$fn = "update.txt";
$content = stripslashes($_POST['content']);
$fp = fopen($fn,"w") or die ("Error opening file in write mode!");
fputs($fp,$content);
fclose($fp) or die ("Error closing file!");
echo "<meta http-equiv="refresh" content="0; url=../" />\n";

?>
Thanks much.

E
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

Code: Select all

if(!empty($_POST['content']))
{
// your code here
}
?
palmere
Forum Newbie
Posts: 17
Joined: Fri Mar 19, 2004 5:33 pm

Post by palmere »

Thanks much. Spotless.
Post Reply