我不能为我的生活得到这种简单的形式......
怎么了?
<form action="" method="post">
<input type="text" name="kupongkode" placeholder=" Kupongkode?"> <input
type="submit" value="✓" id="kupongkodeKnapp">
</form>
<?php
if (isset ( $_POST ['kupongkodeKnapp'] )) {
if ($_POST ['kupongkode'] == "TEST")
echo "Godkjent!";
else
echo "Ikke godkjent";
}
?>
答案 0 :(得分:2)
您提交的名称属性缺失
<form action="index.php" method="post">
<input type="text" name="kupongkode" placeholder=" Kupongkode?">
<input type="submit" value="✓" name="kupongkodeKnapp" id="kupongkodeKnapp">
</form>
<?php
if (isset ( $_POST ['kupongkodeKnapp'] )) {
if ($_POST ['kupongkode'] == "TEST")
echo "Godkjent!";
else
echo "Ikke godkjent";
}
?>
答案 1 :(得分:1)
在表单提交上,您总是希望通过&#34; name&#34;来引用表单元素。属性&#34 ;.这是前端(JavaScript)和后端(PHP或其他)的情况。
<?php
if (isset ( $_POST ['kupongkode'] )) {
if ($_POST ['kupongkode'] == "TEST")
echo "Godkjent!";
else
echo "Ikke godkjent";
}
答案 2 :(得分:0)
使用isset
您应该通过this链接。
答案 3 :(得分:0)
你犯了一个错误,你应该使用name
代替id
:
<form action="" method="post">
<input type="text" name="kupongkode" placeholder=" Kupongkode?"> <input
type="submit" value="✓" name="kupongkodeKnapp">
</form>
<?php
if (isset ( $_POST ['kupongkodeKnapp'] )) {
if ($_POST ['kupongkode'] == "TEST")
echo "Godkjent!";
else
echo "Ikke godkjent";
}
?>
答案 4 :(得分:0)
试试这样:
<form action="" method="post">
<input type="text" name="kupongkode" placeholder=" Kupongkode?">
<input type="submit" value="✓" id="kupongkodeKnapp">
</form>
<?php
if (isset($_POST)){
if ($_POST ['kupongkode'] == "TEST")
echo "Godkjent!";
else
echo "Ikke godkjent";
}
?>