php中form表单提交保留空格和回车
nl2br
nl2br(string)
本函数将换行字符转换成 HTML 换行的 <br> 指令。
- <?php
- include('conn.php');
- if($_POST){
- $title=nl2br($_POST['title']);
- $sql="insert into `home` (`id`,`username`,`banner_imgurl`) values (NULL,'$title','1')";
- mysql_query($sql);
- }
- ?>
- <form action="" method="post">
- <textarea name="title"></textarea>
- <input type="submit" value="提交" />
- </form>
- <?php
- include('conn.php');
- $sql="select * from `home`";
- $query=mysql_query($sql);
- while($row=mysql_fetch_array($query)){
- echo $row['username'];
- }
- ?>
本文转自许琴 51CTO博客,原文链接:http://blog.51cto.com/xuqin/1092302,如需转载请自行联系原作者