Notice: Undefined index:address? whats this?

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Paul NIcolai Sunga
    New Member
    • Mar 2008
    • 43

    Notice: Undefined index:address? whats this?

    here's the code i use..then the error appeared something like that..
    Notice: Undefined index:address


    Code:
    <?php 
    $a1 = $_POST['address'];
    if($a1 = "")
    {
    echo "Empty Address Field.";
    }
    ?>

    and all other codes like this have the same error though it is not empty.


    Code:
    $surname = $_POST['surname'];
    $sex = $_POST['sex'];
    $firstname = $_POST['firstname'];
    $cstatus = $_POST['cstatus'];
    $middlename = $_POST['middlename'];
    $weight = $_POST['weight'];
    $age = $_POST['age'];
    $blood = $_POST['blood'];
    $pnumber = $_POST['pnumber'];
    $year = $_POST['year'];
    $month = $_POST['month'];
    $day = $_POST['day'];
    $email = $_POST['email'];
    $address = $_POST['address'];
    $category = $_POST['category'];
    $team = $_POST['team'];
    $browse = $_POST['Browse'];
    $password = $_POST['password'];
    $person = $_POST['person'];
    $contactadd = $_POST['contactadd'];
    $relationship = $_POST['relationship'];
    $ecnumber = $_POST['ecnumber'];

    what's wrong?



    thanks.
  • Dormilich
    Recognized Expert Expert
    • Aug 2008
    • 8694

    #2
    maybe you didn't post? print out $_POST to see, what it actually contains.

    Comment

    • Paul NIcolai Sunga
      New Member
      • Mar 2008
      • 43

      #3
      thanks but it is stil not working.. i tried to print out but it produce the same error..

      Comment

      • Dormilich
        Recognized Expert Expert
        • Aug 2008
        • 8694

        #4
        Originally posted by Paul NIcolai Sunga
        i tried to print out but it produce the same error..
        how did you print out???

        Comment

        • Paul NIcolai Sunga
          New Member
          • Mar 2008
          • 43

          #5
          Code:
          <?php 
          
          $a1 = $_POST['address'];
          echo $a1;
          
          ?>

          Comment

          • Markus
            Recognized Expert Expert
            • Jun 2007
            • 6092

            #6
            Do a print_r() on $_POST, is what Dormilich meant. print_r() will traverse an array and print it in readable format.

            Code:
            <?php
            
            print_r($_POST);
            
            ?>

            Comment

            • Paul NIcolai Sunga
              New Member
              • Mar 2008
              • 43

              #7
              this is what contains in my redirect page:

              Code:
               
              $Submit = $_POST['Submit'];
              
              if($Submit == 'Submit')
              {
              //GETTING DATA IN FORM
              $surname = $_POST['surname'];
              $sex = $_POST['sex'];
              $firstname = $_POST['firstname'];
              $cstatus = $_POST['cstatus'];
              $middlename = $_POST['middlename'];
              $weight = $_POST['weight'];
              $age = $_POST['age'];
              $blood = $_POST['blood'];
              $pnumber = $_POST['pnumber'];
              $year = $_POST['year'];
              $month = $_POST['month'];
              $day = $_POST['day'];
              $email = $_POST['email'];
              $address = $_POST['address'];
              $category = $_POST['category'];
              $team = $_POST['team'];
              $browse = $_POST['Browse'];
              $password = $_POST['password'];
              $person = $_POST['person'];
              $contactadd = $_POST['contactadd'];
              $relationship = $_POST['relationship'];
              $ecnumber = $_POST['ecnumber'];
              $others = $_POST['others'];
              
              echo $firstname, $middlename, $surname, $address, $category, $year $month $day, $age, $pnumber, $email, $sex, $weight, $cstatus;
              }
              header('Location:registration.php');
              exit();

              then the error appears like this:
              Notice: Undefined index: Submit in C:\wamp\www\red irect.php on line 3
              this is the line 3: $Submit = $_POST['Submit'];
              instead of printing the data in forms the error appear.

              why? im so confused about it.

              thanks

              Comment

              • Canabeez
                New Member
                • Jul 2009
                • 126

                #8
                Try printing out $_REQUEST instead of $_POST, see what you get:
                [code=php]
                var_dump($_REQU EST);[/code]

                Comment

                • Markus
                  Recognized Expert Expert
                  • Jun 2007
                  • 6092

                  #9
                  Ignored again.

                  *leaving thread*

                  Comment

                  • ak1dnar
                    Recognized Expert Top Contributor
                    • Jan 2007
                    • 1584

                    #10
                    This error appears because of your PHP error reporting configuration settings. Normally , it appears when your variable is not properly set. There are two ways to fix this issue.

                    Check if $_POST['VAR_NAME_HERE'] is set before using it.
                    example:
                    Code:
                    if (!isset($_POST['VAR_NAME_HERE']))
                    {
                    //If not isset provide a dummy value here
                    $_POST['VAR_NAME_HERE'] = "";
                    }
                    or simply ignore the NOTICES from your error reporting settings.to do that modify your error_reporting settings on php.ini to
                    Code:
                    error_reporting = E_ALL & ~E_NOTICE
                    or else add this line to the top of your code
                    Code:
                    <?php error_reporting (E_ALL ^ E_NOTICE); ?>

                    Comment

                    • Paul NIcolai Sunga
                      New Member
                      • Mar 2008
                      • 43

                      #11
                      thanks a lot!!




                      is it common that E_NOTICE is always showing?

                      Comment

                      • Paul NIcolai Sunga
                        New Member
                        • Mar 2008
                        • 43

                        #12
                        i found the path to php.ini but the problem is i dont know how to configure it.

                        Comment

                        • ak1dnar
                          Recognized Expert Top Contributor
                          • Jan 2007
                          • 1584

                          #13
                          find this line
                          error_reporting = E_ALL
                          and modify it with
                          error_reporting = E_ALL & ~E_NOTICE

                          save it and make sure to restart the web server too before test it.

                          Comment

                          Working...