Using PHP & Curl to login to my websites form

前端 未结 6 2172
爱一瞬间的悲伤
爱一瞬间的悲伤 2020-12-05 05:06

Im trying to login to my useraccount on a site i use to download files from so i can automatically grab the file without me having to visit the site.

This is

6条回答
  •  陌清茗
    陌清茗 (楼主)
    2020-12-05 06:11

    $postdata = "username=".$username."&userpass=".$password"; 
    

    change to:

    $postdata = "username=".$username."&userpass=".$password;
    

    And also do you have this like this?

    $url="http://www.yourdomain.com/news.php";
    

    Also add this curl_setopt ($ch, CURLOPT_FOLLOWLOCATION, 1);.

    And also this may help:

    $headers  = array();
    
    $headers[] = 'application/xhtml+voice+xml;version=1.2, application/x-xhtml+voice+xml;version=1.2, text/html, application/xml;q=0.9, application/xhtml+xml, image/png, image/jpeg, image/gif, image/x-xbitmap, */*;q=0.1';
    $headers[] = 'Connection: Keep-Alive';
    $headers[] = 'Content-type: application/x-www-form-urlencoded;charset=UTF-8';
    
    curl_setopt ($ch, CURLOPT_HTTPHEADER, $headers);
    curl_setopt ($ch, CURLOPT_HEADER, 1);
    

提交回复
热议问题