1
我有一个代码登录到网站。它在像WordPress这样的网站上工作,但在网站我想登录什么都没有发生。哪里没有错误信息或任何东西。 这里是我的代码:卷曲登录到网站不工作
<?php
print" <head>
<base href='http://www.example.com/'/>
</head>";
$url = 'http://www.example.com/login.php?';
$postdata = 'username=dasds&password=frkm';
$referer = $url;
$cookie = "cookie.txt" ;
$ch = curl_init();
curl_setopt ($ch, CURLOPT_URL, $url);
curl_setopt ($ch, CURLOPT_SSL_VERIFYPEER, true);
curl_setopt ($ch, CURLOPT_USERAGENT, "Mozilla/5.0 (Windows NT 6.1; WOW64; rv:13.0) Gecko/20100101 Firefox/13.0");
curl_setopt($ch,CURLOPT_COOKIESESSION,false);
curl_setopt ($ch, CURLOPT_TIMEOUT, 60);
curl_setopt ($ch, CURLOPT_FOLLOWLOCATION, false);
curl_setopt ($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt ($ch, CURLOPT_COOKIEJAR, $cookie);
curl_setopt ($ch, CURLOPT_POSTFIELDS, $postdata);
curl_setopt ($ch, CURLOPT_POST, 1);
$result = curl_exec ($ch);
print $result;
curl_close($ch);
?>
和HTML形式:
<form name="form" method="post" action="/login.php">
<label class="registration" for="username">
<span>Username</span>
<input name="username" type="text" id="username" size="30"/>
</label>
<label class="registration" for="password">
<span>Password</span>
<input name="password" type="password" id="password"/>
</label>
<input type="submit" name="Login" value="Login"/>
</form>
欢迎来到Stackoverflow。请在发布*任何*问题之前,按照您需要确认的[问题建议](http://stackoverflow.com/questions/ask-advice)进行确认。请记住,只有你想要的东西,你问自己如何编程不符合本身的编程问题。 – hakre