<?php
if(isset($_POST['query'])){
$query = $_POST['query'];
}
//create connection
$conn = mysql_connect("localhost", "root", "password");
mysql_select_db("bookclub", $conn);
?>
<html>
<head>
<meta charset="UTF-8">
<link rel="stylesheet" type="text/css" href="style.css">
<title> SearchBar </title>
</head>
<body>
<header>
<form action="index.php" method="POST">
<input type="text" name="query" placeholder="search...." maxlength="30" id="search">
<input type="submit" name="submit" id="searchbtn" value="GO" />
</form>
<?php
$query = mysql_query("SELECT * FROM list WHERE BookName LIKE'%".$_POST['query'] ."%' OR Author LIKE '%".$_POST['query'] ."%' OR Price LIKE'%".$_POST['query']."%'"); //line 53
$num_rows = mysql_num_rows($query);
while($row = mysql_fetch_array($query)){
$BookName = $row['BookName'];
$Author = $row['Author'];
$Price = $row['Price'];
echo '<h3>'.$BookName.' By </h3> <p>' . $Author.'</p> Price: ' . $Price.'<br />' ;
}
?>
</header>
</body>
Notice: Undefined index: query in C:\xampp\htdocs\index.php on line 53
Tried many alternatives but did not get any solution for this.Even though there is an error I am able to search the contents in my db tables.I want this error to be removed.