So i've made this login function using PHP and im having trouble asking a question correctly to the phpmyadmin database, basically the question i ask now is "SELECT * FROM User" which only lets the first registered user in the database login.
The question i really want to ask is something like this: fetch the column where the username thats being inputed matches with the column.
This is my take on it:
"SELECT * FROM User WHERE username = '$_post['username_input']'"
but i just get error message.
How should i ask this question? thanks for the help in advance!
<form method='post'>
<table>
<tr><td></td><td><input type='text' name='username_input' /></td></tr>
<tr><td></td><td><input type='text' name='password_input' /></td></tr>
<tr><td></td><td><input type='submit' name='submit' value='Logga in' /></td></tr>
</table>
<form>
<?php
$link = mysqli_connect ("localhost", "xxxxxxxx", "xxxxxxx", "xxxxxxx");
$sql_result = $link->query ("SELECT * FROM User");
$rad = mysqli_fetch_array ($sql_result);
$columnuser = $rad['username'];
$columnpassword = $rad['password'];
if (isset($_POST['submit'])) {
if ($_POST['username_input'] == $columnuser && md5 ($_POST['password_input']) == $columnpassword) {
$_SESSION['log_in'] = true;
header("Location: administration.php");
}
else {
echo "Fel användarnamn eller lösenord, vänligen försök igen.";
}
}
mysqli_close ($link);
?>