Nachdem ich viele Dinge ausprobiert habe, die ich bei Google gefunden habe und hier auf stackoverflow kann ich mein Problem nicht lösen. Also beschloss ich, die Gemeinde zu fragen.Aufruf einer Memberfunktion bind_param() auf null/während der Aktualisierungsabfrage
Das ist mein PHP-Code für die Post Form bekommen:
if (isset($_POST['submit'])) {
$firstPW = $_POST['password'];
$secondPW = $_POST['repassword'];
//DEBUG VARIABLES AREN'T NULL.
echo nl2br(trim($firstPW) . "\n" . trim($secondPW) . "\n" . $email . "\n" . trim($token) . "\n");
if ($firstPW == $secondPW) {
$pwunequal = FALSE;
$hashedpass = password_hash(trim($firstPW), PASSWORD_BCRYPT, array('cost' => 10));
// PASSWORD HASH ISN'T NULL
echo nl2br(trim($hashedpass) . "\n");
// $con is defined in another file which is required at the top.
$ustmt = $con->prepare("UPDATE users SET `Password` = ? WHERE Email = ?");
if ($ustmt !== FALSE) {
$ustmt->bind_param("ss", $hashedpass, $email);
$ustmt->execute();
echo "Successfully updated.";
$ustmt->close();
$con->close();
} else {
echo "NULL";
}
} else {
$pwunequal = TRUE;
}
}
Wenn ich das Formular abschicken ich folgende Ausgabe:
Value of $firstPW
Value of $secondPW
Value of $email (got email through $_GET[] before)
Value of $hashedpass
Warning: mysqli::prepare(): Couldn't fetch mysqli on line 49
Fatal error: Uncaught Error: Call to a member function bind_param() on null on line 51
Keine der oben Genannten ist null.
Meine Datenbank-Setup:
The column "Password" = varchar(200), collation = utf8_general_ci, not null, default none
The column "Email" = varchar(200), collation = utf8_general_ci, not null, default none
Ich hoffe, dass jemand meinen Fehler erkennen kann, denn ich es selbst nicht finden kann. :/ Jeder hilfreiche Kommentar wird sehr geschätzt.
Wenn 'mysqli :: prepare()' nicht Sie, dass man überprüfen sollte. Zeigen Sie uns, wie Sie '$ con' einrichten. – m02ph3u5