The file test2.php consists of these simple forms:

<?php

for($i=0; $i<=5; $i++){

echo "<form action='reset4.php' method='get' name='yourForm'>";

echo "<button type='submit' value='delete' name='remove_" . $i . "' class='deletebtn'>X</button>";

echo "</form>";

}

?>

It submits to reset4.php which is this simple code:

<?php
header("Location: test2.php");
exit;


for($i=0; $i<=5; $i++){
if (isset($_REQUEST["remove_$i"])){
echo "Deleted";
}}

?>

But it doesn't work. The $_REQUEST doesn't populate the address field and it apparently never gets submitted to reset4.php like it should. This is such a simple program, I can't imagine why it doesn't work.

    If this is the start of the form-handling file, then the actual form-handling will never happen, since it's redirecting you back to the form page:

    <?php
    header("Location: test2.php");
    exit;
    

      When I remove exit it still doesn't work.

        Because if you still have the header then the redirect is still the first thing that happens on the page.

          When I use the following, it still doesn't work:

          <?php

          for($i=0; $i<=5; $i++){

          echo "<form action='' method='get' name='yourForm'>";

          echo "<button type='submit' value='remove_" . $i . "' name='delete' class='deletebtn'>X</button>";
          echo "</form>";

          }
          for($i=0; $i<=5; $i++){
          if (isset($REQUEST["remove$i"])){
          echo "delete";
          echo "Received Value: " . $REQUEST["remove$i"];
          }
          }

          ?>

            makamo66 The underscores were suppressed.

            Yeah, that would be because you're not posting your code with the appropriate [‍code]...[/code] tags around it.

            I'll also point out that you don't have any form fields named remove_1 ... remove_5. You have five buttons all named delete that have remove_1 ... remove_5 as values.

              Write a Reply...