Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 2 of 2
  1. #1
    New Coder
    Join Date
    Jul 2009
    Posts
    68
    Thanks
    1
    Thanked 1 Time in 1 Post

    Textarea empty; Do not update.

    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:

    PHP Code:
    <?php
    session_start
    ();

    $sText=$_POST['textdata'];
    $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.

  • #2
    Senior Coder kbluhm's Avatar
    Join Date
    Apr 2007
    Location
    Philadelphia, PA, USA
    Posts
    1,509
    Thanks
    3
    Thanked 258 Times in 254 Posts
    PHP Code:
    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.
    Last edited by kbluhm; 01-22-2010 at 02:30 AM.


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •