我使用通用 HTML 标签在 WordPress 插件中创建了一个表单。我刚刚使用 echo 测试了文本框提交的值,它工作正常。我需要在提交表单后在同一页面中重定向或显示成功/失败消息。表单提交后如何显示成功或失败消息?
小智 2
<form method="post" role="form">
<div class="form-group">
<label for="txt">Enter Text</label>
<input type="text" class="form-control" id="txt1" name="txt1" value="" placeholder="Enter your text..." />
</div>
<button type="submit" name="send" class="btn btn-default">Send</button>
</form>
<?php
if(isset($_POST['send'])) {
$txt1 = trim($_POST['txt1']);
$count=0;
if(empty($txt1)) {
echo '<div class="error">Please enter your text.</div>';
} else {
header("Location: http://www.yourwebsite.com/user.php");
$count=1;
if($count=1)
{
echo '<label for="msg">Succes Message</label>';
}
}
}
?>
Run Code Online (Sandbox Code Playgroud)
归档时间: |
|
查看次数: |
9420 次 |
最近记录: |