1. Computer problem? Tech Support Guy is completely free -- paid for by advertisers and donations. Click here to join today! If you're new to Tech Support Guy, we highly recommend that you visit our Guide for New Members.

checking to see if a field is not empty with !empty()

Discussion in 'Web Design & Development' started by knight_47, Feb 3, 2007.

Thread Status:
Not open for further replies.
Advertisement
  1. knight_47

    knight_47 Thread Starter

    Joined:
    Mar 14, 2006
    Messages:
    941
    Is it possible to set a variable to a POST and make sure it's not emtpy?

    For example:
    PHP:
    $test = !emtpy($_POST['test']) or die("Error");
    would that code work?
     
  2. Big-K

    Big-K

    Joined:
    Nov 22, 2003
    Messages:
    6,052
    yes, for example if you send in a form then this would execute.

    if(!empty($_POST['the_field']))
    echo "this ain't empty";
     
  3. namenotfound

    namenotfound

    Joined:
    Apr 30, 2005
    Messages:
    3,012
    Don't you need braces?

    if(!empty($_POST['the_field'])) {
    echo "this ain't empty";
    }
     
  4. brendandonhu

    brendandonhu

    Joined:
    Jul 8, 2002
    Messages:
    14,681
    Brackets aren't required. You don't need an if for this though
    Code:
    strlen($_POST['test']) or die('Error');
     
As Seen On
As Seen On...

Welcome to Tech Support Guy!

Are you looking for the solution to your computer problem? Join our site today to ask your question. This site is completely free -- paid for by advertisers and donations.

If you're not already familiar with forums, watch our Welcome Guide to get started.

Join over 733,556 other people just like you!

Thread Status:
Not open for further replies.

Short URL to this thread: https://techguy.org/541006

  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice