I have a search page that is working but is generating an error despite working. The error is
Notice: Undefined index: var1 in C:\Program Files\EasyPHP-DevServer-13.1VC9\data\localweb\my portable files\air\search.php on line 58 Invalid form value:
The code that i have is here below. The first line in the code below is the line 58
$var1 = str_replace(array('%','_'),'',$_POST['var1']);
if (!$var1)
{
exit('Invalid form value: '.$var1);
}
$query = "SELECT * FROM holder WHERE Surname LIKE :search OR FirstName LIKE :search OR Variable Like :search OR Number Like :search GROUP BY holder.EmployeeID";
$statement = $db->prepare($query);
$statement->bindValue(':search', '%' . $var1 . '%', PDO::PARAM_INT);
echo "<table border='1' cellpadding='10'>";
echo "<tr> <th>Surname</th> <th>First Name</th> <th>Rank</th> <th>Number</th></tr>";
$statement->execute();
/* Fetch all of the remaining rows in the result set */
print("Here are the results of your search Sir:\n");
$statement->setFetchMode(PDO::FETCH_ASSOC); // Set the fetch mode.
while ($row = $statement->fetch())
{
$Surname = $row['Surname'];
$FirstName = $row['FirstName'];
$Variable = $row['Variable'];
$Variable = $row['Number'];
echo "<tr>";
echo '<td>' . $row['Surname'] . '</td>';
echo '<td>' . $row['FirstName'] . '</td>';
echo '<td>' . $row['Variable'] . '</td>';
echo '<td>' . $row['Number'] . '</td>';
echo '<td><a href="details.php?EmployeeID=' . $row['EmployeeID'] . '">Details</a></td>';