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