[英]How can i submit my form in php to echo a response?
I'm trying to make a form with radio checkboxes and a textbox. 我正在尝试制作一个带有单选框和一个文本框的表单。 The goal is to receive what is set in the radio buttons/the textbox and echo it (For now).
目的是接收单选按钮/文本框中设置的内容并回显它(现在)。 The future goal is to upload it to MySQL, but that wont be a problem.
将来的目标是将其上传到MySQL,但这不会成为问题。
EDIT: i forgot to set the method="post" that solved the problem 编辑:我忘记设置解决问题的method =“ post”
echo "<tr>";
echo '<div class="error infonachricht">'
.'<center>Aktuell liegt ein Beurlaubungsantrag von '
.$beurlauber.' vom '.$startdate.' bis zum '.$enddate.' vor:<br><br>"'
.$begruendung
.'"<form>Annahme:<br>'.
'<input type="radio" name="annahme'.$i.'" value="Ja">Ja<br>
<input type="radio" name="annahme'.$i.'" value="Nein">Nein<br>
Neuer Grund: '.'<input type="text" size="30" maxlength="100" name="grund"><br> <br>
<input type="submit" name="clicked'.$i.'" value="Absenden">'.
'</form>';
if (isset($_POST['clicked'.$i])){
if (isset ($_POST['annahme'.$i])){
if ($_POST['annahme'.$i]=="Ja"){
echo "Ja";
}
if ($_POST['annahme'.$i]=="Nein"){
echo "Nein";
}
}
}
echo '</center></div>';
echo "</tr>";
I expected it to show either "Ja" or "Nein", but it didn't show anything at all. 我希望它显示“ Ja”或“ Nein”,但什么也没有显示。
when you create a form in html it should have a method. 当您在html中创建表单时,它应该有一个方法。 So if you add method="POST" in your tag, it should be work as a post form.
因此,如果您在标签中添加method =“ POST”,则它应该可以作为发布表单。
Also i recommend you to change your inputs to a <option>
tag. 我也建议您将输入更改为
<option>
标记。 You can edit with css if you want some buttons. 如果需要一些按钮,可以使用css进行编辑。 Your form should be looking like that;
您的表格应该看起来像这样;
<form method="POST" action="/action_page.php">
<select name="annahme">
<option value="ja">Ja</option>
<option value="nein">Nein</option>
</select>
<input type="submit" value="Submit">
</form>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.