Ive been trying to make a simple mySQL program to just check if a key is in a databse. However, i am failing, any ideas? I have tried looping around the entire database to find the value, though no luck. If anyone could shed some light on this it would be very thankful. Also The database looks like this:
VALUE
wouehourhfwfrhg
rwihewoughwourh
fw8rhfouirhushr
wrohwroghwhrwhr
And the program just checks if the input in the box is in the database.
<html>
<head>
<?php
require_once ("config.php");
function isKeyValid($key){
$query='SELECT `Value` FROM `InviteKeys` WHERE `Used`=0';
$response = @mysqli_query($link,$query);
if($response)
{
echo($key);
while($row = mysqli_fetch_array($response))
{
echo $row . "<br>";
if($key==$row)
return 1;
}
return 0;
}
}
if(isset($_POST['submit'])){
$key = trim($_POST['keyInput']);
if(isKeyValid($key))
{
echo("KYS");
}
else {
echo("Kys less");
}
}
?>
</head>
<body>
<form action='/keyTester.php' method="post">
<input type="text" name="keyInput" size="30" placeholder = "Username" class = "inpoot"><br>
<input type="submit" name="submit" value="Submw">
</form>
</body>
</html>