2016-07-22 51 views
0

我在提交表單時遇到了這些錯誤。可能是什麼問題?謝謝如何繼續提取GPS定位器上的數據?

1)! )致命錯誤:未捕獲的異常 'PDOException' 與消息 'SQLSTATE [HY093]:無效參數數:參數沒有定義'

2)PDOException:SQLSTATE [HY093]:無效參數數:參數沒有在

定義

這是代碼

if (!empty($_POST) && !empty($_POST['pseudo']) && !empty($_POST['pass'])) { 
require 'dbconnection.php'; 
require 'functions.php'; 
$req = $pdo->prepare('SELECT * FROM utilisateurs WHERE (login = :pseudo) AND activated != NULL'); 
$req->execute(['login' => $_POST['pseudo']]); 
$user = $req->fetch(); 

if (password_verify($_POST['pass'], $user->password)) { 
    session_start(); 
    $_SESSION['auth'] = $user; 
    header('Location: index.php'); 
    exit(); 
}else{ 
    $_SESSION['flash']['danger'] = 'Login ou mot de passe incorrecte'; 
} 

}

回答

0

您需要更改執行語句

$req->execute([':pseudo' => $_POST['pseudo']]); 

因爲您創建佔位符pseudologin

,並使用IS NOT NULL檢查NULL

$req = $pdo->prepare('SELECT * FROM utilisateurs WHERE (login = :pseudo) AND activated IS NOT NULL'); 
$req->execute([':pseudo' => $_POST['pseudo']]); 
+0

有你檢查的解決方案? – Saty

+0

是的,但我得到了這個時間_Fatal錯誤:無法在第5_行的C:\ wamp64 \ www \ wintrack \ functions.php中重新聲明debug()(以前在C:\ wamp64 \ www \ wintrack \ functions.php:3中聲明) –

+0

您是否創建了名稱爲'debug()'的函數? – Saty

0
<?php 
    if (!empty($_POST) && !empty($_POST['pseudo']) && !empty($_POST['pass'])) { 
    require 'dbconnection.php'; 
    //require 'functions.php'; 
    $req = $pdo->prepare('SELECT * FROM utilisateurs WHERE (login = :pseudo) AND activated IS NOT NULL'); 
    $req->execute([':pseudo' => $_POST['pseudo']]); 
    $user = $req->fetch(); 



if (password_verify($_POST['pass'], $user->password)) { 
     session_start(); 
     $_SESSION['auth'] = $user; 
     header('Location: index.php'); 
     exit(); 
    }else{ 
     $_SESSION['flash']['danger'] = 'Login ou mot de passe incorrecte'; 
    } 

} 
+0

在if(password_verify .... –