I take it that your target sript has something like isset($_POST['submit']) .
2 things:
1 your form should have a validation function in the page head to check the input before posting the form data. Any javascript source will have dozens to choose from.
<script type="text/javascript">
<!-- Begin
function val_search() {
if (document.form.search_string.value == "")
{ alert ("Please enter a search string");
document.form.search_string.focus();
return false;
}
else {
return true;
}
}
// End -->
</script>
</head>
That will ensure that however the form is submitted, it has a string to search on. (you could use the same function to check if the submit button had been pressed and return false + set focus ,ie not post, untill it had)
- having validated the presense of data, our target script has no need to check if the submit button was pressed, but only if isset($_POST['search_string']), and this only incase of bookmarks or missdirection.