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

Status
This thread has been Locked and is not open to further replies. Please start a New Thread if you're having a similar issue. View our Welcome Guide to learn how to use this site.

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?
 
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";
 
Joined
Apr 30, 2005
Messages
3,012
Big-K said:
yes, for example if you send in a form then this would execute.

if(!empty($_POST['the_field']))
echo "this ain't empty";
Don't you need braces?

if(!empty($_POST['the_field'])) {
echo "this ain't empty";
}
 
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');
 
Status
This thread has been Locked and is not open to further replies. Please start a New Thread if you're having a similar issue. View our Welcome Guide to learn how to use this site.

Users Who Are Viewing This Thread (Users: 0, Guests: 1)

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 807,865 other people just like you!

Latest posts

Staff online

Top