-1

I want a form with 4 submit buttons. Once any of them is pressed, they shell call the same page with different content. To determine which content it is, I will write a PHP Script, but I have not come that far yet. My Problem on the way is, that I need to pass the value along.

I found an answer to my question in here ( Two submit buttons in one form ). I copied and adjusted the code but it is not working. When I want to access the $_POST array with my defined name, it says it is an unknown index. This is my relevant code so far.

<div>
    <form action="nutzerverwaltung.php" method="post">
        <input type="submit" class="nv_select" name="nv_select" value="Nutzer hinzufuegen" />
        <input type="submit" class="nv_select" name="nv_select" value="Nutzer loeschen" />
        <input type="submit" class="nv_select" name="nv_select" value="Nutzer bearbeiten" />
        <input type="submit" class="nv_select" name="nv_select" value="Alle Nutzer anzeigen" />
    </form>
    <br />
</div>

<?php if ($_POST["nv_select"] == "Nutzer hinzufuegen") echo "Hallo"; ?>

What am I doing wrong??

John

Community
  • 1
  • 1
JRsz
  • 2,891
  • 4
  • 28
  • 44

2 Answers2

5

Maybe you want to write name = "nv_select". You forget equal. Of course name atributes should be different nv_select1, nv_select2 etc.

TheBosti
  • 1,354
  • 13
  • 19
1

with input type="button" instead of "submit" you should be able to achieve the desired result.

regards, Max

mxg
  • 111
  • 7