我现在想用php登陆一个网站,然后再采取其他操作。网站是用post的方法获取信息的。我怎样才能实现把我的用户名和密码传递进那个网站呢?
    不胜感激!

解决方案 »

  1.   

    <form action="那个网站的url" method="post">
    <input type="user" name="user" value="">
    <input type="password" name="password" value="">
    <input type="submit" value="提交">
    </form>  也可以用隐藏域传过去。
      

  2.   

    可是这样的话,还是得按那个提交按钮,然后就转到那个页面。 我希望能运行这个php文件就直接登录进那个页面,然后直接进行我想要的操作。
      

  3.   

    那你用js控制。让页面加载完就提交表单就行了。window.onload=function(){
          document.表单名.submit();
    }
      

  4.   

    直接通过$_post['name'],$_post['pwd'],可以取到值。
      

  5.   


    <script>
    window.onload=function(){
          document.test.submit();
    }
    </script>
    <form action="那个网站的url" name="test" method="post">
    <input type="user" name="user" value="">
    <input type="password" name="password" value="">
    </form>
      

  6.   

    <html>
    <head>
    <title></title>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    </head>
    <scrip>
    function login(){
          document.xxx.submit();
    }</script>
    <body onload="login()">
    <form action="那个网站的url" method="post" name="xxx" style="display:none;">
    <input type="user" name="user" value="这里填上你的用户名">
    <input type="password" name="password" value="这里填上你的密码">
    <input type="submit" value="提交">
    </form>
    </body>
    </html>
      

  7.   

    几句PHP代码就可以实现$post = array();
    $post = array(
    "name"    =>'admin'
            'pwd'     =>'12345'
     );$ch = curl_init();
    curl_setopt($ch, CURLOPT_URL, 你要去的url地址);
    curl_setopt($ch, CURLOPT_POST, true);
    curl_setopt($ch, CURLOPT_HEADER, 0);
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
    curl_setopt($ch, CURLOPT_USERAGENT, "Xpub pusher Ver 1.0");
    curl_setopt($ch, CURLOPT_POST, true);
    curl_setopt($ch, CURLOPT_VERBOSE, 1);
    curl_setopt($ch, CURLOPT_POSTFIELDS, $post);
    $r = curl_exec($ch);
    echo $r;
      

  8.   

    这位,我之前在网上也搜到了这个,但我不知道curl要配置或安装什么东西?