By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
455,775 Members | 1,325 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 455,775 IT Pros & Developers. It's quick & easy.

checking if a cell is empty

P: n/a
Hi,
I need a condition in update form where before the form is updated, I have
to check if the value of a cell is empty or not. If it is not empty, an
error is shown and if empty, it is updated.
What I am doing wrong in the script ( $_POST['helper1_pos'] gets value from
the form). It shows error even if the cell is empty.

if (!is_null($_POST['helper1_pos'])) {
echo "Sorry! Helper 1 position already volunteered.";
exit;
}
else {
//update
}

Thanks.
Ashok.
Jul 17 '05 #1
Share this Question
Share on Google+
5 Replies


P: n/a
*** Ashok wrote/escribió (Mon, 23 May 2005 13:36:08 +0400):
What I am doing wrong in the script ( $_POST['helper1_pos'] gets value from
the form). It shows error even if the cell is empty.

if (!is_null($_POST['helper1_pos'])) {
echo "Sorry! Helper 1 position already volunteered.";
exit;
}


PHP does not set to NULL post variables when they're empty. You can merely
check if they're empty strings (because, in the end, all form fields are
sent as strings).
--
-- Álvaro G. Vicario - Burgos, Spain
-- http://bits.demogracia.com - Mi sitio sobre programación web
-- Don't e-mail me your questions, post them to the group
--
Jul 17 '05 #2

P: n/a
Per the manual, a variable is considered to be NULL if

*it has been assigned the constant NULL.
*it has not been set to any value yet.
*it has been unset().

I'm guessing $_POST['helper1_pos'] is being set to an empty string or
something.

-aaron

Jul 17 '05 #3

P: n/a
Change to
if ($_POST["helper1_pos"] == "") {
echo "nothing there blah blah etc etc";
}

"Ashok" <no**@mail.ru> wrote in message news:d6***********@gavrilo.mtu.ru...
Hi,
I need a condition in update form where before the form is updated, I have
to check if the value of a cell is empty or not. If it is not empty, an
error is shown and if empty, it is updated.
What I am doing wrong in the script ( $_POST['helper1_pos'] gets value from the form). It shows error even if the cell is empty.

if (!is_null($_POST['helper1_pos'])) {
echo "Sorry! Helper 1 position already volunteered.";
exit;
}
else {
//update
}

Thanks.
Ashok.

Jul 17 '05 #4

P: n/a
or:
if(empty($_POST["helper1_pos"])
echo "nothing here";

Although that if statement will evaluate to true if the box contains
the string "0".

Jul 17 '05 #5

P: n/a
Ashok napisa³(a):
Hi,
I need a condition in update form where before the form is updated, I have
to check if the value of a cell is empty or not. If it is not empty, an
error is shown and if empty, it is updated.
What I am doing wrong in the script ( $_POST['helper1_pos'] gets value from
the form). It shows error even if the cell is empty.

if (!is_null($_POST['helper1_pos'])) {
echo "Sorry! Helper 1 position already volunteered.";
exit;
}
else {
//update
}

Thanks.
Ashok.


Hi,

function is_null give true when $_POST['helper1_pos'] = NULL.
You must understand NULL is not ''.

use function empty()

if (empty($_POST['helper1_pos'])) {
echo "Sorry! Helper 1 position already volunteered.";
exit;
}
else {
//update
}
Jul 17 '05 #6

This discussion thread is closed

Replies have been disabled for this discussion.