View Full Version : Textarea empty; Do not update.

01-22-2010, 01:22 AM
I'm currently building a template system so a user can update a php file by using the admin panel. Here is the code I have so far:


$config = stripslashes($sText); //Whatever you want in the .html place it here.

// do all your file writing here
$handle = fopen("../../template/includes/terms.php","w+"); // Opens the script with w+ (writing intentions) and stores it in variable for quicker access.
fputs($handle,$config); // Write the contents of $config to the file opened in $handle
fclose($handle); // Close the opened file


The problem is if $sText is empty it'll wipe the file. Is there any way I'd be able to see if the text area is empty and stop it updating if it is?

Thanks. :)

01-22-2010, 01:28 AM
if ( '' == trim( $sText ) )
// empty, do not update

You could also use empty(), but if you want to allow "empty" values like 0, etc, it will not work as desired.

EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum