Ich habe versucht, eine Anmeldung Validierung mit der Website verknüpft, aber funktioniert nicht. Hier ist mein Code:Login Validierungsfehler auf der Website (CURL)
public function login() {
$username = $this->input->post('login', 'true');
$password = $this->input->post('password', 'true');
if($this->ci_curl->loginIdws($username, $password) == false) {
echo "<script> alert('Invalid Username & Password');
window.location.href = 'index';
</script>";
}
else
{
$this->load->view('curl/thread');
}
}
Wenn die Anmeldung fehlschlägt, ist alles in Ordnung, aber wenn die Anmeldung erfolgreich ist, wird die Seite zeigt alert('Invalid Username & Password')
... Wie kann ich dieses Problem beheben? Sie vergleichen den Rückgabewert von
if($this->ci_curl->loginIdws($username,$password)==false){
:
Hier ist meine Bibliothek:
public function loginIdws($username, $password) {
$url = 'http://forum.idws.id/login/login';
$data = '_xfToken=&cookie_check=1&login='.$username.'&password='.$password.'&redirect=http://forum.idws.id/';
$ch = curl_init();
curl_setopt($ch, CURLOPT_COOKIEJAR, "cookie.txt");
curl_setopt($ch, CURLOPT_COOKIEFILE, "cookie.txt");
curl_setopt($ch, CURLOPT_TIMEOUT, 40000);
curl_setopt($ch, CURLOPT_HEADER, FALSE);
curl_setopt($ch, CURLOPT_NOBODY, FALSE);
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_USERAGENT, "Mozilla/5.0 (Windows NT 6.1; rv:45.0) Gecko/20100101 Firefox/45.0");
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_REFERER, $_SERVER['REQUEST_URI']);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
curl_setopt($ch, CURLOPT_POST, TRUE);
curl_setopt($ch, CURLOPT_POSTFIELDS, $data);
$baca = curl_exec($ch);
if($baca == = FALSE) {
die(curl_error($ch));
}
$info = curl_getinfo($ch);
curl_setopt($ch, CURLOPT_URL, "http://forum.idws.id/account/");
curl_setopt($ch, CURLOPT_POST, 0);
$baca2 = curl_exec($ch);
curl_close($ch);
$pecah1 = explode('<fieldset>', $baca2);
$pecah2 = explode('</fieldset>', $pecah1[1]);
echo "<fieldset>";
echo $pecah2[0];
echo "</fieldset>";
}
und das ist meine Ansicht:
< ? php echo form_open('curly/login'); ? >
<label>Username :</label>
<input id = "name" name = "login" type = "text">
<label>Password : </label>
<input id = "password" name = "password" type = "password">
<input type = "submit" name = "submit" id = "submit" value = "Login">
Teilen Sie Ihre vollständigen Code ..! Kann nicht nur von diesem Code helfen ..! –
hat meinen vollen Code hinzugefügt –
verwendest du codeigniter ??? –