Detecting if post data empty???

This is a discussion on Detecting if post data empty??? within the alt.comp.lang.php forums, part of the PHP Programming Forums category; Hello, I'm having a problem detecting if post data is empty. I've got a search form on one ...


Go Back   Usenet Forums > PHP Programming Forums > alt.comp.lang.php

FAQ Members List Calendar Search Today's Posts Mark Forums Read
  #1 (permalink)  
Old 05-21-2005
Marv
 
Posts: n/a
Default Detecting if post data empty???

Hello,

I'm having a problem detecting if post data is empty.

I've got a search form on one page, that posts to a form on another
page. If the user doesn't enter anything, then I wanted to make the
variable equal a dot. But for some reason, even if you leave the form
input blank and just hit submit, the post variable is not detected as
empty using either isset($var) or empty($var). Neither of these work
and the form page that gathers the post data assumes that the variable
holds some value.

What would that value be? How else can I detect if the nothing has
been entered on the search form?

Thanks
Reply With Quote
  #2 (permalink)  
Old 05-21-2005
bonfils
 
Posts: n/a
Default Re: Detecting if post data empty???

"Marv" <marv@mister.com> wrote:

> Hello,
>
> I'm having a problem detecting if post data is empty.
>
> I've got a search form on one page, that posts to a form on another
> page. If the user doesn't enter anything, then I wanted to make the
> variable equal a dot. But for some reason, even if you leave the form
> input blank and just hit submit, the post variable is not detected as
> empty using either isset($var) or empty($var). Neither of these work
> and the form page that gathers the post data assumes that the variable
> holds some value.
>
> What would that value be? How else can I detect if the nothing has
> been entered on the search form?
>
> Thanks


Something like

if (trim($_POST['fieldname'])!='')
{
// whatever ...
}

Because yes, you're right. When the HTML form is created, the input values
by default are all empty strings. And when posted, all of these end up in
the $_POST array.

--
bonfils
http://kim.bonfils.com


Reply With Quote
Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are Off
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



All times are GMT +1. The time now is 12:18 PM.


Powered by vBulletin® Version 3.7.3
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO 3.0.0