php表单上的多个单词
我希望能够在文本1之后添加更多单词,而不仅仅是一个有效单词php表单上的多个单词,php,Php,我希望能够在文本1之后添加更多单词,而不仅仅是一个有效单词 <?php if ($_POST['discount'] == 'text1') echo "Discount Applied!"; else header('Location:fifapack.html'); ?> 折扣代码: 这是我的html。您可以通过这种方式发送一些折扣: <div id="dicount"> <form action=discounts.php
<?php
if ($_POST['discount'] == 'text1')
echo "Discount Applied!";
else
header('Location:fifapack.html');
?>
折扣代码:
这是我的html。您可以通过这种方式发送一些折扣:
<div id="dicount">
<form action=discounts.php method=post>
<center>Discount Code:<input type=text name=discount>
<input type=submit value=Apply>
</center>
</div>
要确定您的帖子中是否有text1,您只需使用:
$b = filter_input(INPUT_POST, 'discount', FILTER_SANITIZE_STRING, FILTER_REQUIRE_ARRAY);
if($b) {
// Do whatever you like with the array of discounts
}
如果我理解正确,您希望根据更多信息验证$\u POST[“折扣”] 言语
你想说什么解释清楚这就是你想要的。。如果你可能已经看到($揠u POST['discount']='text1'|$揠u POST['discount']=='text3'),你会得到3个完全不同的答案。也许你应该更清楚你想要实现什么。表单中唯一有效的“折扣”是text1。我想有更多的,然后只是一段文字工作
$b = filter_input(INPUT_POST, 'discount', FILTER_SANITIZE_STRING, FILTER_REQUIRE_ARRAY);
if($b) {
// Do whatever you like with the array of discounts
}
if (strpos($_POST['discount'], 'text1')) {
...
}
<?php
if (($_POST['discount'] == 'text1') or ($_POST['discount'] == 'whatever')) {
echo "Discount Applied!";
}
else {
header('Location:fifapack.html');
}
?>