這期內容當中小編將會給大家?guī)碛嘘P使用PHP怎么模擬登陸功能,文章內容豐富且以專業(yè)的角度為大家分析和敘述,閱讀完這篇文章希望大家可以有所收獲。
1、curl實現(xiàn)模擬登陸的代碼,(只是實現(xiàn)服務器與服務器建立會話,其實并沒有在客戶端與服務器之間建立會話)
<?php $cookie_jar = tempnam('./tmp','cookie'); $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, 'http://192.168.0.22/logincheck.php'); curl_setopt($ch, CURLOPT_POST, 1); $request = 'UNAME=admin&PASSWORD=123456'; curl_setopt($ch, CURLOPT_POSTFIELDS, $request); //把返回來的cookie信息保存在$cookie_jar文件中 curl_setopt($ch, CURLOPT_COOKIEJAR, $cookie_jar); //設定返回的數(shù)據(jù)是否自動顯示 curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); //設定是否顯示頭信息 curl_setopt($ch, CURLOPT_HEADER, false); //設定是否輸出頁面內容 curl_setopt($ch, CURLOPT_NOBODY, false); curl_exec($ch); curl_close($ch); //get data after login $ch3 = curl_init(); curl_setopt($ch3, CURLOPT_URL, 'http://192.168.0.22/general/'); curl_setopt($ch3, CURLOPT_HEADER, false); curl_setopt($ch3, CURLOPT_RETURNTRANSFER, 1); curl_setopt($ch3, CURLOPT_COOKIEFILE, $cookie_jar); $orders = curl_exec($ch3); echo $orders; exit; echo '<pre>'; echo strip_tags($orders); echo '</pre>'; curl_close($ch3); ?>
2、通過隱藏的iframe實現(xiàn)客戶端與服務器端的通信(肯能帶來一定的安全隱患)
<html> <title></title> <body> <? $goURL="http://192.168.0.22/general/email/"; ?> <iframe name="hiddenLoginFrame" onload="get_pass()" src="ceshi1.php" id="hiddenLoginFrame" width=0 height=0 frameborder=0 scrolling=no > </iframe> <script Language="JavaScript"> function get_pass() { window.open("<?=$goURL ?>"); window.close(); } </script> </body> </html>
ceshi1.php
<html> <head> <title>ceshi</title> </head> <body onload="get_pass1();"> <form name="form1" method="post" target="hiddenLoginFrame" action="http://192.168.0.22/logincheck.php"> <input type="text" value="admin" name="UNAME"> <input type="text" value="123456" name="PASSWORD"> </form> </body> <script Language="JavaScript"> function get_pass1() { //document.form1.action=u_url; document.form1.submit(); } </script> </html>
上述就是小編為大家分享的使用PHP怎么模擬登陸功能了,如果剛好有類似的疑惑,不妨參照上述分析進行理解。如果想知道更多相關知識,歡迎關注創(chuàng)新互聯(lián)行業(yè)資訊頻道。
分享標題:使用PHP怎么模擬登陸功能-創(chuàng)新互聯(lián)
URL鏈接:http://chinadenli.net/article4/dgjsoe.html
成都網(wǎng)站建設公司_創(chuàng)新互聯(lián),為您提供商城網(wǎng)站、品牌網(wǎng)站建設、python、虛擬主機、動態(tài)網(wǎng)站、網(wǎng)站排名
聲明:本網(wǎng)站發(fā)布的內容(圖片、視頻和文字)以用戶投稿、用戶轉載內容為主,如果涉及侵權請盡快告知,我們將會在第一時間刪除。文章觀點不代表本網(wǎng)站立場,如需處理請聯(lián)系客服。電話:028-86922220;郵箱:631063699@qq.com。內容未經(jīng)允許不得轉載,或轉載時需注明來源: 創(chuàng)新互聯(lián)
猜你還喜歡下面的內容