Results 1 to 2 of 2

Thread: Many nulls in blank $_POST field..How?

  1. #1
    Join Date
    Nov 2009
    Posts
    9

    Question Many nulls in blank $_POST field..How?

    I've been stymied in trying to test for blank fields entered on an HTML form. All tests have been failing to identify a "blank", ( user entered nothing), field. I finally broke down the resultant $_POST variable in my called PHP and found that it's length was 11 characters and that each of those 11 characters was ascii 0 (null). While I could test on ascii values, I'm thinking I must be missing something since everything I've read makes it look like simple tests for if var =="". Any help here would be appreciated.

  2. #2
    Join Date
    Feb 2007
    Location
    Ireland
    Posts
    1,007
    Quote Originally Posted by oldsportbiker View Post
    I've been stymied in trying to test for blank fields entered on an HTML form. All tests have been failing to identify a "blank", ( user entered nothing), field. I finally broke down the resultant $_POST variable in my called PHP and found that it's length was 11 characters and that each of those 11 characters was ascii 0 (null). While I could test on ascii values, I'm thinking I must be missing something since everything I've read makes it look like simple tests for if var =="". Any help here would be appreciated.
    By default all fields in a form at not set, so the isset($_POST['field']) should return false.
    If a user clicks inside a field, it is set but null. The empty($_POST['field']) should help you there. There are alot of variable handling functions that you should take a look at.

    PHP Code:
    <?php
    if(isset($_POST['field']) && !empty($_POST['field'])) {
        
    $field $_POST['field'];
    }
    else {
        
    // error message
    }
    ?>
    “The best thing about a boolean is even if you are wrong, you are only off by a bit.”

Similar Threads

  1. Blank Web Page is displayed when a Link on the main page is clicked
    By Balasubramaniam in forum Web Design, HTML Reference and CSS
    Replies: 0
    Last Post: 15 Mar 2006, 03:47 AM
  2. Blank spots displaying within Graphic - mystery
    By terepan in forum Graphic Design
    Replies: 0
    Last Post: 13 Feb 2006, 07:41 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •