hi every one I have a problem with my search on my site I don't understand why it give me this error
this is my form code
and this is the page which have the php code
any idea why it give me this note about "Undefined index: search" and why the results come "0"
Thanks for you all.
this is my form code
Code:
<form action="index.php?cat=search_results&learn_id=1" method="post">
<div id="topSearchBodyStyle">
<input type="text" name="search" class="topSearchTextBackground" />
</div>
<div id="topSearchButtonStyle">
<input type="submit" name="submit" class="topSearchButtonBackground" value="" />
</div>
</form>
Code:
<?php
$getSearch = $_POST['search'];
trim($getSearch);
if(!get_magic_quotes_gpc()) {
$getSearch = addslashes($getSearch);
}
$connectToDb = "select * from tutorials where tutorial_title like '%.$getSearch.%'";
$searchResults = $db->query($connectToDb) or die($db->error);
if ($searchResults){
$numResultas = $searchResults ->num_rows;
echo "<p>Found : " . $numResultas . "</p>";
while($row = mysqli_fetch_array($searchResults)) {
echo $row['tutorial_title'];
}
}else{
echo "cant connect";
}
?>
any idea why it give me this note about "Undefined index: search" and why the results come "0"
Thanks for you all.
Comment