-3

I am passing user entered numerical values into a database using text inputs. I want the db to execute the insert for all numerical values greater than or equal to 0 however if nothing is in the textbox I do not want the database to execute the insert. So I would like to distinguish between 0 and no entry. isset would still return true. any help would be great Thank You

I have my code written, I just need help with the logic test of determining whether zero or null.

user2101459
  • 579
  • 2
  • 8
  • 19

1 Answers1

2

You want to use isset in this case as it will detect if the textbox is null or not set however it will pass if it is 0

if (isset($_POST['textbox']))

You can further combine it with strlen like this:

if (isset($_POST['textbox']) && strlen($_POST['textbox']) > 0)
Prix
  • 19,417
  • 15
  • 73
  • 132