Undefined index error PHP

前端 未结 9 850
春和景丽
春和景丽 2020-12-01 08:24

I\'m new in PHP and I\'m getting this error:

Notice: Undefined index: productid in /var/www/test/modifyform.php on line 32

Notice: Undef

相关标签:
9条回答
  • 2020-12-01 08:34

    To remove this error, in your html form you should do the following in enctype:

    <form  enctype="multipart/form-data">
    

    The following down is the cause of that error i.e if you start with form-data in enctype, so you should start with multipart:

    <form enctype="form-data/multipart">
    
    0 讨论(0)
  • 2020-12-01 08:35

    If you are using wamp server , then i recommend you to use xampp server . you . i get this error in less than i minute but i resolved this by using (isset) function . and i get no error . and after that i remove (isset) function and i don,t see any error.

    by the way i am using xampp server

    0 讨论(0)
  • 2020-12-01 08:37

    this error occurred sometime method attribute ( valid passing method ) Error option : method="get" but called by $Fname = $_POST["name"]; or

           method="post" but  called by  $Fname = $_GET["name"];
    

    More info visit http://www.doordie.co.in/index.php

    0 讨论(0)
  • 2020-12-01 08:43

    Apparently the index 'productid' is missing from your html form. Inspect your html inputs first. eg <input type="text" name="productid" value=""> But this will handle the current error PHP is raising.

      $rowID = isset($_POST['rowID']) ? $_POST['rowID'] : '';
      $productid = isset($_POST['productid']) ? $_POST['productid'] : '';
      $name = isset($_POST['name']) ? $_POST['name'] : '';
      $price = isset($_POST['price']) ? $_POST['price'] : '';
      $description = isset($_POST['description']) ? $_POST['description'] : '';
    
    0 讨论(0)
  • 2020-12-01 08:43

    TRY

    <?php
    
      $rowID=$productid=$name=$price=$description="";  
    
       if (isset($_POST['submit'])) {
          $rowID = $_POST['rowID'];
          $productid = $_POST['productid']; //this is line 32 and so on...
          $name = $_POST['name'];
          $price = $_POST['price'];
          $description = $_POST['description'];
    
    }
    
    0 讨论(0)
  • 2020-12-01 08:44

    Try:

    <?php
    
    if (isset($_POST['name'])) {
        $name = $_POST['name'];
    }
    
    if (isset($_POST['price'])) {
        $price = $_POST['price'];
    }
    
    if (isset($_POST['description'])) {
        $description = $_POST['description'];
    }
    
    ?>
    
    0 讨论(0)
提交回复
热议问题