表单POST操作不起作用

Why wont this work?

<form action="" method="POST">
<input type="text" class="searchBar" name="domain" /><input type="button" value="SEARCH" class="searchButton" id="srch" />
</form>


<? print $_POST['domain']; ?>

I have tried putting it into a var too. I just got an error.

Thanks

Edit: Suggestions have been made of changing button to submit, but my jQuery bug's up.

<script type="text/javascript">
$('#srch').click(function(){ 
      $('#notActive').attr('id','Active'); 
});

$(document).ready(function(){

  // Hide div 2 by default
  $('#Active').hide();

  $('#srch').click(function(){ 
      $('#notActive').hide();
      $('#Active').fadeIn();
  });
});
</script>

I have managed to change the Button to Submit by using the action as javascript: void(0); for my form.

You can't access the posted variable before a form is submitted.

if (isset($_POST['domain'])) {
    // a form is submitted that contains the 'domain' parameter
    print $_POST['domain'];
}

The form cant submit if contains no type="submit" input.

<input type="button" /> cant submit form. You should add <input type="submit" /> to form.

Try setting an action:

<form action="index.php" method="POST">.

Also, change your second line to this:

<? if (isset($_POST['domain'])) echo ($_POST['domain']); ?>