Rumah >pembangunan bahagian belakang >tutorial php > 怎么用cookie防止用户的灌水回复
如何用cookie防止用户的灌水回复?
今天没事瞎点 点到 凤凰网的一个链接了 http://yue.ifeng.com/y/detail_2011_12/07/11160676_0.shtml
评论框 内容是 :文明上网,登陆评论!
直接点按钮 js alert 请填写评论内容
再点一下文本框 文本框内容变成:请您先登录,再发布评论。
再点按钮 就提交了
打开的页面中的最新评论里就有了。然后我就复制了部分html
<!-- Code highlighting produced by Actipro CodeHighlighter (freeware) http://www.CodeHighlighter.com/ --> <meta http-equiv="Content-Type" content="text/html" charset="utf-8">
<!-- Code highlighting produced by Actipro CodeHighlighter (freeware) http://www.CodeHighlighter.com/ --> header("content-type:text/html;charset:utf-8;"); /* chId 21202 content mmmmmmmmm docId 11160676 docName 吴卓羲女友张馨予家中大尺度内衣自拍照火辣曝光 docUrl http://yue.ifeng.com/y/detail_2011_12/07/11160676_0.shtml */ $url = "http://comment.ifeng.com/post.php"; //$url = "http://localhost/php/index.php"; $data = array( 'content'=>'xxxxxxxxxxoooooooooooo', 'docId'=>11160676, 'docName'=>'吴卓羲女友张馨予家中大尺度内衣自拍照火辣曝光', 'docUrl'=>'http://yue.ifeng.com/y/detail_2011_12/07/11160676_0.shtml', 'chId'=>21202 ); $ret = http_post($url,$data); var_dump($ret); function http_post($url, $data) { $ch = curl_init(); curl_setopt($ch, CURLOPT_HEADER,1); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); curl_setopt($ch, CURLOPT_URL, $url); curl_setopt($ch, CURLOPT_POST, 1); $data = http_build_query($data); curl_setopt($ch, CURLOPT_POSTFIELDS, $data); curl_setopt($ch, CURLOPT_REFERER, "http://yue.ifeng.com/y/detail_2011_12/07/11160676_0.shtml"); $cookie = "userid=1323532473389_2814"; curl_setopt($ch, CURLOPT_COOKIE, $cookie); $rs = curl_exec($ch); curl_close($ch); return $rs; }