Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

"Undefined index" when quoting array key

Tags:

forms

php

I have a form in index.php

<?php 
  echo '<form action="update_act.php" method="POST">';
  echo '<input type="submit" name="'.$row['act_name'].'" value="edit">
  echo </form>
?>

Here $row['act_name'] is a value fetched from database.

My update_act.php file is

<?php
   echo "Old Activity Name : ".$_POST['$row[\'act_name\']'];
?>

But I am getting an error Undefined index: $row['act_name'] in C:\wamp\www\ps\activity\update_act.php.

I want to have different names for different submits but I am not able to get its value in another page. Is there any way for it?

like image 509
Satish Avatar asked May 03 '26 16:05

Satish


1 Answers

I don't exactly know, what you're trying to do, but if the value of variable $row['act_name'] is same in both of the cases (form page and update script), then you can access to that this way:

echo "Old Activity Name : ".$_POST[$row['act_name']];
like image 143
Radek Simko Avatar answered May 05 '26 05:05

Radek Simko



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!