HTML form submit button does not write in $_POST

佐手、 提交于 2019-12-13 09:23:42

问题


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


回答1:


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




回答2:


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

regards, Max



来源:https://stackoverflow.com/questions/27969615/html-form-submit-button-does-not-write-in-post

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!