Hi i have implemented search functionality by following in youtube but the problem is whenever i enter the name and click on search button it is displaying that entered text in URL as mentioned below.
<?php session_start();
if(isset($_GET['search']))
{
$valueToSearch=$_POST['valueToSearch'];
$query="SELECT * FROM appointment WHERE 'first_name' LIKE '%".$valueToSearch."%'";
$search=filtertable($query);
}
else{
$query="SELECT * FROM appointment";
$search_result=filtertable($query);
}
function filterTable($query)
{
include 'includes/db.php';
$filter_Result=mysqli_query($conn,$query);
return $filter_Result;
}
?>
<form>
<input name="valueToSearch" type="text" placeholder="Search by Name"/>
<input type="submit" name="search" value="Search"/>
<div class="body">
<div class="table-responsive">
<table class="table table-striped">
<thead>
<tr>
<th>#</th>
<th>Name</th>
<th>Gender</th>
<th>Department</th>
<th>Phonenumber</th>
</tr>
</thead>
<tbody>
<?php
while ($row=mysqli_fetch_array($search_result)):?>
<tr>
<td><?php echo $row['appoin_id'];?></td>
<td><?php echo $row['first_name'];?> </td>
<td><?php echo $row['gender'];?></td>
<td><?php echo $row['department'];?></td>
<td><?php echo $row['phone_no'];?></td>
</tr>
<?php endwhile;?>
</tbody>
</table>
</div>
</div>
</form>
it is displaying in the url as like this
http://website.com/admin/search.php?valueToSearch=df&search=Search
And displaying the error in error log as PHP Notice: Undefined index: valueToSearch in admin/search.php on line 7.