i want to create a login system but unfortunately this error appear:
Call to a member function fetchColumn() on a non-object in error
please anyone can help me because this is the first a post in this forum...
<form action="login_controller.php" method="POST">
<span class="user_label">Username: </span>
<input class="username" type="text" name="username"><p>
<span class="pass_label">Password: </span>
<input class="password" type="password" name="password"><p>
<input class="submit" type="submit" name="submit" value="Login">
</form>
<?php
require_once 'config/config.php';
if (isset($_POST['submit']) && $_POST['submit'] == 'Login') {
$username = $_POST['username'];
$password = $_POST['password'];
if (!empty($username) && !empty($password)) {
$users_count = $pdo->query("SELECT COUNT(username)
FROM users
WHERE username = {$username}");
$count_all = $users_count->fetchColumn();
print_r($count_all);
}
else {
header('Location: login.php');
}
}