Undefined index error PHP

0 votes

I'm getting this error:

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

Notice: Undefined index: name in /var/www/test/modifyform.php on line 33

Notice: Undefined index: price in /var/www/test/modifyform.php on line 34

Notice: Undefined index: description in /var/www/test/modifyform.php on line 35

The code:

<form action="<?php echo $_SERVER['PHP_SELF'];?>" method="POST">
   <input type="hidden" name="rowID" value="<?php echo $rowID;?>">

   <p>
      Product ID:<br />
      <input type="text" name="productid" size="8" maxlength="8" value="<?php echo $productid;?>" />
   </p>

   <p>
      Name:<br />
      <input type="text" name="name" size="25" maxlength="25" value="<?php echo $name;?>" />
   </p>

   <p>
      Price:<br />
      <input type="text" name="price" size="6" maxlength="6" value="<?php echo $price;?>" />
   </p>

   <p>
      Description:<br />
      <textarea name="description" rows="5" cols="30">
      <?php echo $description;?></textarea>
   </p>

   <p>
      <input type="submit" name="submit" value="Submit!" />
   </p>
   </form>
   <?php
   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'];

}

Can someone please tell me what's wrong here?

Jun 11, 2022 in PHP by narikkadan
• 63,600 points
546 views

No answer to this question. Be the first to respond.

Your answer

Your name to display (optional):
Privacy: Your email address will only be used for sending these notifications.

Related Questions In PHP

0 votes
1 answer

Error:“Notice: Undefined variable”, “Notice: Undefined index”, and “Notice: Undefined offset” using PHP

Hello @kartik, The best way for getting input string is: $value ...READ MORE

answered Apr 1, 2020 in PHP by Niroj
• 82,840 points
37,525 views
0 votes
1 answer

Error:Undefined index: barangay in C:\xampp\htdocs\TextBlast\homepage\insert.php on line 22

Hello @ Regina, First checks whether a variable is ...READ MORE

answered Aug 14, 2020 in PHP by Niroj
• 82,840 points
5,778 views
0 votes
1 answer

Notice: Undefined index: bid in C:\xampp\htdocs\userac\courier_management_system-master\courier_management_system-master\addstaff.php on line 130

Hello @saima , Before you extract values from $_POST ,$_SESSION, ...READ MORE

answered Sep 14, 2020 in PHP by Niroj
• 82,840 points
2,853 views
0 votes
1 answer

Error:PHP Notice: Undefined offset: 1

Hello @kartik, Change $data[$parts[0]] = $parts[1]; to if ( ! isset($parts[1])) ...READ MORE

answered Oct 20, 2020 in PHP by Niroj
• 82,840 points
7,654 views
0 votes
1 answer

Fatal error: Call to undefined function imap_open() in PHP

Hello @kartik, In Ubuntu for install imap use sudo ...READ MORE

answered Oct 29, 2020 in PHP by Niroj
• 82,840 points
5,638 views
0 votes
1 answer

Fatal error: Call to undefined function ImageCreate() in /home/t1g01/phplot.php on line 248

Hello @kartik, Your server most like does not ...READ MORE

answered Nov 18, 2020 in PHP by Niroj
• 82,840 points
6,267 views
0 votes
0 answers

Getting PHP registration form to connect with MYSQL

I'm building a test site and my ...READ MORE

May 30, 2022 in PHP by Kichu
• 19,040 points
500 views
0 votes
0 answers

PHP Notice: Undefined offset: 1 with array when reading data

I am getting this error : PHP Notice: ...READ MORE

Jun 9, 2022 in PHP by Kichu
• 19,040 points
1,341 views
0 votes
0 answers

Why use $_SERVER['PHP_SELF'] instead of ""

In a form on a PHP page, ...READ MORE

Jun 25, 2022 in PHP by narikkadan
• 63,600 points
532 views
0 votes
0 answers

How to call a PHP function on the click of a button

The two buttons on my functioncalling.php page ...READ MORE

Jul 24, 2022 in PHP by Kithuzzz
• 38,000 points
10,901 views
webinar REGISTER FOR FREE WEBINAR X
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP