很多站长朋友们都不太清楚php模拟登录vpn,今天小编就来给大家整理php模拟登录vpn,希望对各位有所帮助,具体内容如下:
本文目录一览: 1、 PHP模拟用户登录模块 2、 如何通过php程序模拟用户登录 3、 怎样用php中的curl模拟登陆 4、 php 模拟 登录 PHP模拟用户登录模块html(login.html)
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "">
<html xmlns="">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>用户登录页面</title>
<script language="javascript">
function check(){
var user = document.getElementById("user");
var passwd = document.getElementById("passwd");
if(user.value.length == 0){
alert("用户名不能为空!");
return false;
}
if(passwd.value.length < 6){
alert("密码至少6位!");
return false;
}
}
</script>
</head>
<body>
<div style=" width:300px; height:200px; margin:auto auto;">
<form name="login" method="post" action="check_login.php">
<table width="300" height="200" cellpadding="0" cellspacing="0" border="1px">
<tr>
<td height="70">用户名:</td>
<td><input id="user" name="username" type="text" /></td>
</tr>
<tr>
<td height="78">密码</td>
<td><input id="passwd" name="password" type="password" /></td>
</tr>
<tr>
<td colspan="2"><center><input type="submit" value="登录" onclick="return check();" /><input type="reset" value="重置" /></center></td>
</tr>
</table>
</form>
</div>
</body>
</html>
php(check_login.php)
<?php
/*
* 验证登录页
* 2015-6-6
* 预设用户名admin,密码1234567,
* 如果相同则显示登录成功!,错误则显示用户或密码错误;
*/
$username = $_POST['username'];
$password = $_POST['password'];
if($username == 'admin' $password =='1234567'){
echo "登录成功!";
}else{
echo "用户或密码错误";
}
?>
如何通过php程序模拟用户登录模拟用户可以用php的curl的post,例如
$url = "";
$post_data = array ("username" => "uzuzuz","password" => "12345");
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
// post数据
curl_setopt($ch, CURLOPT_POST, 1);
// post的变量
curl_setopt($ch, CURLOPT_POSTFIELDS, $post_data);
$output = curl_exec($ch);
curl_close($ch);
//打印获得的数据
print_r($output);
具体参考:
怎样用php中的curl模拟登陆在我的博客《PHP cURL模拟登录与采集分析过程详解》做了详细的介绍,步骤有:
1. 访问目标网站
2. 打开Firebug(快捷键:F12)
3. 清除【Cookie】
4. 重新访问目标网站
5. 设置【网络】为[保持]状态
6. 填写表单,提交登录请求
7. 利用【网络】,分析提交信息
8. 复制请求的cURL命令
9. 分析命令传输的参数与Cookie和前面页面响应内容的关联性
10. 如果遇到Cookie和响应内容都无法查找到的参数,Ctrl+S保存当前页面为全部,利用文本搜索该参数的位置
11. 利用cURL命令组装模拟登录程序
详情请参考博客内容:
php 模拟 登录打开网站读取cookie然后判断是否存在cookie如果存在在提示他是否登录,顺便把帐号和密码存cookie中就行了
关于php模拟登录vpn的介绍到此就结束了,不知道本篇文章是否对您有帮助呢?如果你还想了解更多此类信息,记得收藏关注本站,我们会不定期更新哦。