How can I insert search box in page.tpl? How can I insert search box(search block) in my theme programmatically?
According to your tag, you're looking for a D7 solution. The Drupal 7 page.tpl.php doesn't have the $search_box variable anymore. However you can add it in a preprocess function in your template.php:

&lt;?php
/*
 *  Preprocess page.tpl.php to inject the $search_box variable back into D7.
 */
function MYTHEME_preprocess_page(&amp;$variables){
  $search_box = drupal_render(drupal_get_form('search_form'));
  $variables['search_box'] = $search_box;
}


Then you just need to print the variable in your page.tpl.php:

&lt;?php print $search_box; ?&gt;


You could also use module_invoke, but you shouldn't have php logic in template files:

&lt;?php
  $block = module_invoke('search', 'block_view', 'search');
  print render($block); 
?&gt;