php 模拟POST提交的2种方法详解
发布时间:2020-12-13 06:23:14 所属栏目:PHP教程 来源:网络整理
导读:代码如下: $post_data = array(); $post_data['clientname'] = "test08"; $post_data['clientpasswd'] = "test08"; $post_data['submit'] = "submit"; $url='http://xxx.xxx.xxx.xx/xx/xxx/top.php'; $o=""; foreach ($post_data as $k=>$v) { $o.= "$k=".ur
代码如下: $post_data = array(); $post_data['clientname'] = "test08"; $post_data['clientpasswd'] = "test08"; $post_data['submit'] = "submit"; $url='http://xxx.xxx.xxx.xx/xx/xxx/top.php'; $o=""; foreach ($post_data as $k=>$v) { $o.= "$k=".urlencode($v)."&"; } $post_data=substr($o,-1); $ch = curl_init(); curl_setopt($ch,CURLOPT_POST,1); curl_setopt($ch,CURLOPT_HEADER,0); curl_setopt($ch,CURLOPT_URL,$url); //为了支持cookie curl_setopt($ch,CURLOPT_COOKIEJAR,'cookie.txt'); curl_setopt($ch,CURLOPT_POSTFIELDS,$post_data); $result = curl_exec($ch); 代码如下: $URL=‘http://xxx.xxx.xxx.xx/xx/xxx/top.php'; $post_data['clientname'] = "test08"; $post_data['clientpasswd'] = "test08"; $post_data['submit'] = "ログイン"; $referrer=""; // parsing the given URL $URL_Info=parse_url($URL); // Building referrer if($referrer=="") // if not given use this script as referrer $referrer=
(编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |