正在回答 回答被采纳积分+1
3回答
qq_ionicRoyKent_04116743
2017-04-25 23:24:26
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 | header( 'content-type:text/html;charset=utf-8' ); date_default_timezone_set( 'PRC' ); $filename = "msg.txt" ; $msgs = array (); //检测文件是否存在 if ( file_exists ( $filename )){ //读取文件中的内容 $string = file_get_contents ( $filename ); if ( strlen ( $string )>0){ $msgs =unserialize( $string ); } } //检测用户是否点击了提交按钮 if (isset( $_POST [ 'pubMsg' ])){ $username = $_POST [ 'username' ]; $title = strip_tags ( $_POST [ 'title' ]); $content = strip_tags ( $_POST [ 'content' ]); $time =time(); //将其组成关联数组 $data =compact( 'username' , 'title' , 'content' , 'time' ); array_push ( $msgs , $data ); $msgs =serialize( $msgs ); if ( file_put_contents ( $filename , $msgs )){ echo "<script>alert('留言成功!');location.href='22-msg.php';</script>" ; } else { echo "<script>alert('留言失败!');location.href='22-msg.php';</script>" ; } } /* |
我写的和讲师是一样的代码!为什么我会报这个错误
恭喜解决一个难题,获得1积分~
来为老师/同学的回答评分吧