I can not find fault here you help? This is my error
Fatal error: Call to undefined method mysqli::bind_param() in
I do not know what was wrong
<?php
if($_SERVER['REQUEST_METHOD'] == 'POST' && isset($_POST))
{
$login = $_POST['login'];
$password = $_POST['password'];
$email = $_POST['email'];
if(empty($login) || empty($password) || empty($email))
{
die('Comeplete all text.');
}
elseif(!filter_var($email, FILTER_VALIDATE_EMAIL))
{
die('Nie poprawny adres E-mail.');
}
else
{
include_once('config.php');
$mysqli = new mysqli('****', '******', '*****') or die ('Fatal Error: '.mysql_error());
if($mysqli -> connect_error)
die('Error Connection:'.$mysqli -> connect_error.'['.$mysqli -> connect_errno.']');
$login = trim(htmlspecialchars($mysqli -> real_escape_string($login)));
$password = hash('sha256', trim(htmlspecialchars($mysqli -> real_escape_string($password))));
$email = trim(htmlspecialchars($mysqli -> real_escape_string($email)));
$ip = $_SERVER['REMOTE_ADDR'];
$stmt = $mysqli -> prepare("INSERT INTO `user`(`id_user`, `login`,`password`,`email`,`added`,`ip`) VALUES('', ? , ? , ? , now(), ?)");
$stmt = $mysqli -> bind_param("ssss", $login, $password, $email, $ip);
if ($stmt) {
$stmt->execute();
echo 'Success';
}
}
}
?>
</section>
</body>
</html>
The problem is, you're using
bind_param
function on MySQL and not the$stmt
variable.The problem is in this line:
Instead of typing:
You should type:
Since the
bind_param
method is only available on themysqli_stmt
class. and not themysqli
.Checkout the documentation here.
bind_param
is a method ofmysqli_stmt
, notmysqli
. It should be:I corrected. And nothing has changed