I've a small issue with this search barre : When I search for the Author or the Session, the search is succesful and everything is fine. But if I search anything in the last box (the Name one) my page is redirected to the site homepage. (with "Page not found" as tab name) I'm really new to php. (and mysql) Is that because I don't give an "action" to the form ?
<form method="post" action="">
<table>
<tbody>
<tr>
<td>Author :</td>
<td><input name="a" type="text" /></td>
<td>Session :</td>
<td><input name="nos" type="text" /></td>
<td>Publication :</td>
<td><input name="name" type="text" /></td>
</tr>
<td>
<input type="submit" value="Search" class="button" />
</td>
</label>
</tbody>
</table>
</form>
<?php
$author = '%'.$_REQUEST['a'].'%';
$nos = '%'.$_REQUEST['nos'].'%';
$name = '%'.$_REQUEST['name'].'%';
$mysqli = new mysqli('localhost', 'mydb', 'Prettygoodpwd', 'the table');
if (mysqli_connect_errno()) {
printf("Connect failed: %s
", mysqli_connect_error());
exit();
}
$sql = 'SELECT AuthorP, NameP
FROM wp_publications
WHERE AuthorP LIKE ?
AND NameOfSessionP LIKE ?
AND NameP LIKE ? ';
if($stmt = $mysqli->prepare($sql))
{
$stmt->bind_param('sss', $author, $nos, $name);
if($stmt->execute())
{
$stmt->store_result();
if($stmt->num_rows >= 1)
{
$resultSet = array();
$stmt->bind_result($au, $na);
while($stmt->fetch())
{
$resultSet[] = array('Author' => $au, 'Name' => $na);
}
}
}else{
echo $stmt->error;
}
}else{
echo $mysqli->error;
}
if(is_array($resultSet))
{
print_r($resultSet);
}
$mysqli -> close();
?>
I tried to remove the last box from the search form : "publication". I expected the problem to be on the "name" box afterward but no. The two first search box work still fine.