这样写能实现跳转到表单界面吗
<button name="btnwant" type="submit"></button>
<?php if (isset($_POST['btnwant'])){
echo '<form action="#" method="post">
<fieldset>
<legend>请留言</legend>
<label>用户名</label><input type="text" name="username" required />
<label>标题</label><input type="text" name="title" required />
<label>内容</label><textarea name="content" rows="5" cols="30" required></textarea>
<hr>
<input type="submit" class="btn btn-primary btn-lg" name="pubMsg" value="发布留言"/>
</fieldset>
</form>';
}?>
正在回答 回答被采纳积分+1
您好,同学可以反馈一下完整的代码,或同学可以回顾一下课程中是如何添加留言的哦~上列代码修改为:需要将button按钮放置在form表单中
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 | < form action = "#" method = "post" > < button name = "btnwant" type = "submit" >提交</ button > </ form > <? php if (isset($_POST['btnwant'])){?> < form action = "#" method = "post" > < fieldset > < legend >请留言</ legend > < label >用户名</ label >< input type = "text" name = "username" required /> < label >标题</ label >< input type = "text" name = "title" required /> < label >内容</ label >< textarea name = "content" rows = "5" cols = "30" required></ textarea > < hr > < input type = "submit" class = "btn btn-primary btn-lg" name = "pubMsg" value = "发布留言" /> </ fieldset > </ form > <? php }?> |
祝学习愉快!
- 参与学习 人
- 提交作业 626 份
- 解答问题 4928 个
想要学好Web后端开发的中流砥柱语言,本阶段为你轻松铺就扎实的基础,从前端网页布局的搭建到后台PHP开发,助你从零基础到掌握主流开发语言。
了解课程
恭喜解决一个难题,获得1积分~
来为老师/同学的回答评分吧