im trying to check if the username and the password put into the input fields are stored in my database. And if there is not then it should give an error message. I have a user in my database atm:
username: alexander
password : alexalex
But however when I run my code to login it doesn't say that it is the right login.
<?php
try{
$db = new PDO('sqlite:users.db');
}
catch(PDOException $err){}
if(isset($_POST['username'])){
$username = $_POST['username'];
$password = $_POST['password'];
try{
$sql = "SELECT * FROM players WHERE username='$username' AND password='$password'";
$st = $db->prepare($sql);
$st->execute();
if($st->fetchColumn() == 1){
//SUCCES LOGIN
}else{
//FAILED LOGIN
}
}catch(PDOException $err){}
}
...HTML CODE...
<form action="" method="POST" class="login-form">
<input type="text" id="one" name="username" placeholder="Username">
<input type="password" id="two" name="password" placeholder="Password">
<input type="submit" value="LOGIN" class="three">
</form>
Very thankful for anyone who can solve this login!