Your field values aren't committed until the page is submitted.
See this example:
<?php
if ($committed) {
..if ($committed != 'not') {
....mail($mailTo, $mailSub, $mailBod);
....unset($committed);
..}
}
echo '<input name="mailTo" size="30" maxlength="30"><br>';
echo '<input name="mailSub" size="30" maxlength="30"><br>';
echo '<textarea name="mailBod" rows="5" cols="30"></textarea><br>';
echo '<input type="hidden" name="committed" value="not">';
echo '<input type="submit" name="button" value="Go" onclick="document.forms[0].committed.value=this.value">';
?>
(The above code would appear between the form tags)
The first pass through the code draws the page.
The second pass begins by checking for the existence and value of the hidden field to see if it is ready to send, sends it if it is, then draws the page once again.
Unlike javascript, which knows of the fields' values as soon as the fields are filled, php requires that the form be submitted to apply the field values to the field (aka variable) names.
Does this help?
Good Luck.
<geek>Steve</geek>
PS, if you copy this code, get rid of the leading dots in the nested ifs - they are there for visual formatting only. ;-)