PHP--Curl模拟POST请求
2017-08-23 12:03
225 查看
curl函数在php中默认是不被支持的,如果需要使用curl函数我们需在改一改你的php.ini文件的设置,找到php_curl.dll去掉前面的”;”
<?php /* *@author:木子 *@var:登入也页面 */ <form action="./App/app_login.php" method="post"> <h3><font color="orange">单点挂号App <span>登录</span><a href="javascript:void(0)" style="list-style: none;" id="relogin" >注册</a></font></h3> <table border="1"> <tr> <td>用户名:</td><td><input type="text" id="u_name" name="u_name" /></td> </tr> <tr> <td>密码:</td><td><input type="password" id="pwd" name="pwd" /></td> </tr> <tr> <td colspan="2" align="center"> <input type="button" value="登入" background="blue"> <input type="button" value="重置" background="blue"> </td> </tr> </table> </form> ?>
<?php /** *@author 木子 *@var [login] 接口登入 *php文件名:app_login.php */ header("content-type:text/html;charset=utf-8"); $uri = "http://www.everydaytest.com/App/login.php"; //参数数组 $data = ['name'=>$_POST['u_name'],'pwd'=>$_POST['pwd']]; $ch = curl_init (); // print_r($ch); curl_setopt ( $ch, CURLOPT_URL, $uri ); curl_setopt ( $ch, CURLOPT_POST, 1 ); curl_setopt ( $ch, CURLOPT_HEADER, 0 ); curl_setopt ( $ch, CURLOPT_RETURNTRANSFER, 1 ); curl_setopt ( $ch, CURLOPT_POSTFIELDS, $data ); $return = curl_exec ( $ch ); curl_close ( $ch ); var_dump($return);
/* * *@author:木子 *php文件名:login.php */ <?php if(isset($_POST['name'])){ if(!empty($_POST['name'])){ echo "您好!".$_POST['name']; } }
相关文章推荐
- PHP中使用CURL模拟发送GET,POST,PUT,DELETE请求
- PHP模拟发送POST请求之五curl基本使用和多线程优化
- CURL封装的php http和https请求网页模拟post get函数
- PHP模拟发送POST请求之五curl基本使用和多线程优化
- php中使用curl模拟get请求和post请求
- php通过CURL模拟post提交请求
- php 模拟浏览器 发送 post 和 get 请求(兼容curl + file_get_contents)
- php curl 模拟post 请求
- PHP之文件操作,http请求数据格式,模拟get和post,CURL模拟请求的使用
- PHP利用CURL方法模拟POST提交数据并获得返回值的小细节
- PHP中使用cURL实现Get和Post请求的方法
- PHP 模拟post请求发送数据
- php利用curl发送 post get del put patch 请求
- php模拟点击器,刷新,清除ie的get和post请求
- PHP中使用CURL实现GET和POST请求
- curl 模拟请求(post为例)
- php的curl函数模拟post、get数据提交,速度非常慢的处理办法
- PHP中使用cURL实现Get和Post请求的方法
- php模拟post请求发送文件
- 在PHP中使用CURL实现GET和POST请求的方法