First time asking on SO. I currently am trying to search a database where the first and last names are seperate. Example:
player_id | first_name | last_name
191 John Smith
192 Larry Citizen
193 Benjamin Example
I am trying to allow users to search this list using a full name only. I currently have the following code once the user hits submit, it calls usersearch.php.
session_start();
include '../con.php';
$player = $_POST['name'];
$sql = "SELECT * FROM characters WHERE (concat(first_name,' ',last_name)) = ($player)";
$result = mysqli_query($conn, $sql);
if (!$row = mysqli_fetch_assoc($result)) {
echo "Found no-one with the name $player. <a href='../search.php'>Try Again?</a>";
} else {
$_SESSION['selplate'] = $row['plate'];
$_SESSION['selname'] = $row['first_name, last_name'];
header("Location: ../profile.php?player=$player");
}
No matter the query it will not find users and always returns "Found no-one with the name $player. Try again?"
This was supposed to be the easy part of this project and I am pulling my hair out.
I have spent over an hour searching SO and Google to no avail so it must be my code? afaik it should work.