• 欢迎访问搞代码网站,推荐使用最新版火狐浏览器和Chrome浏览器访问本网站!
  • 如果您觉得本站非常有看点,那么赶紧使用Ctrl+D 收藏搞代码吧

普通的表单登陆如何修改成php curl模拟表单登陆

php 搞代码 4年前 (2022-01-24) 24次浏览 已收录 0个评论

普通的表单登陆怎么修改成php curl模拟表单登陆

<br />    用户名: <br><br />	<strong>)本文来(源gaodai#ma#com搞@@代~&码*网2</strong><pre>搞代gaodaima码

密码:

2.php

header('Content-Type:text/html;Charset=utf-8');<br />if ($_POST['loginname'] == 'lee' && $_POST['loginpass'] == '123456') {<br />      header('location:http://bbs.gaodaima.com');<br />} else {<br />     <br />} 

请教一下这样的表单怎么修改成模拟登陆 我是这样写的为什么不对呢
新建一个1.php

header('Content-type:text/html;Charset=utf-8');  <br />$user = 'lee';       //登陆用户名   <br />$pass = '123456';    //登陆密码   <br />$post_fields = "loginname={$user}&loginpass={$pass}";<br />$ch = curl_init(); <br />curl_setopt($ch,CURLOPT_URL,'http://localhost/2.php');<br />curl_setopt($ch,CURLOPT_POST,1);<br />curl_setopt($ch,CURLOPT_POSTFIELDS,$post_fields);<br />curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); <br />curl_exec($ch);<br />curl_close($ch);

——解决方案——————–
echo curl_exec($ch);

另外你的2.php是跳转了,并没有返回内容。
改成echo file_get_contnets(‘location:http://bbs.gaodaima.com&#8217;); 试试
——解决方案——————–
header(‘location:http://bbs.gaodaima.com&#8217;);
形成的 http 头
HTTP/1.1 302 Found
Date: Wed, 26 Feb 2014 09:16:38 GMT
location: http://bbs.gaodaima.com
Content-Length: 0
Content-Type: text/html;Charset=utf-8

你不跟着跳转吗?
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
——解决方案——————–
#1 不是说了吗?
echo curl_exec($ch);
你不输出结果怎么能行?

<script id=”allmobilize” charset=”utf-8″ src=”http://a.yunshipei.com/1327c36bdd7197e30fd9f4b48d1a5bcc/allmobilize.min.js”></script&gt;
<meta http-equiv=”Cache-Control” content=”no-transform” />

<link rel=”stylesheet” href=”http://static.gaodaima.com/public/common/toolbar/css/index.css”&gt;

<frameset cols=”230,*” frameborder=”no” border=”0″ framespacing=”0″>
<frame src=”/left_menu” name=”leftFrame” noresize=”noresize” id=”leftFrame” title=”leftFrame” />
<frame src=”/home” name=”mainFrame” id=”mainFrame” title=”mainFrame” />

<body>


搞代码网(gaodaima.com)提供的所有资源部分来自互联网,如果有侵犯您的版权或其他权益,请说明详细缘由并提供版权或权益证明然后发送到邮箱[email protected],我们会在看到邮件的第一时间内为您处理,或直接联系QQ:872152909。本网站采用BY-NC-SA协议进行授权
转载请注明原文链接:普通的表单登陆如何修改成php curl模拟表单登陆

喜欢 (0)
[搞代码]
分享 (0)
发表我的评论
取消评论

表情 贴图 加粗 删除线 居中 斜体 签到

Hi,您需要填写昵称和邮箱!

  • 昵称 (必填)
  • 邮箱 (必填)
  • 网址