Custom category search box for WordPress

In every template file of your theme, even in the header.php you can put

<?php
$term = null;
$btn = __('Search');
if ( is_category() ) { $term = get_queried_object(); }
?>
<form method="get" id="search_form" action="<?php echo home_url(); ?>">
<div>
<input type="text" value="" name="s" id="s" />
<?php
if ($term) {
  $btn = sprintf( __('Search in %s'), $term->name);
?>
<input type="hidden" value="<?php echo $term->term_id; ?>" name="cat" />
<input type="hidden" value="<?php echo $term->name; ?>" name="catname" />
<?php } ?>
<input type="submit" id="search_submit" name="Search" value="<?php echo $btn; ?>"/>
</div>
</form>

If you are viewing a category it will show a category restricted search, in other cases it show a generic search form.

Then in your search.php, to dinamically output the title put something like:

<?php
$searchtitle = isset($_GET['catname']) && ! empty($_GET['catname']) ? 
sprintf( __('Search Results for &quot;%s&quot; in category &quot;%s&quot;'), $_GET['s'], $_GET['catname']) :
sprintf( __('Search Results for &quot;%s&quot;'), $_GET['s']);
?>
<h1><?php echo $searchtitle; ?></h1>