Yeah there are two ways of going about it, as Telos showed. You could just copy and paste the php code at the top of your page (just for ease of reading).
Code:
<?php
if ($_POST['emailSubmit']){
$body = "The following information was just submitted by a user: \n\n Full Name: " . $_POST['name'] . "\n Address: " . $_POST['address'] . "\n City: " . $_POST['city'] . "\n State: " . $_POST['state'] . "\n Age: " . $_POST['age'] . "\n Comment: " . $_POST['comment'];
mail($_POST['emailTo'], "Replace this with what you want the subject to be", $body);
}
?>
<!DOCTYPE ... rest of your code ...
Or you could do it so that the page will show the form, but once it is submitted it will send the email and display a thank you message instead of the form. This code piece would do it:
Code:
<?php
if ($_POST['emailSubmit']){
$body = "The following information was just submitted by a user: \n\n Full Name: " . $_POST['name'] . "\n Address: " . $_POST['address'] . "\n City: " . $_POST['city'] . "\n State: " . $_POST['state'] . "\n Age: " . $_POST['age'] . "\n Comment: " . $_POST['comment'];
mail($_POST['emailTo'], "Replace this with what you want the subject to be", $body);
echo "Thank you, and email has been sent out with your information.";
}else{ // Allow the HTML form to be displayed
?>
<form method="POST" action="<?php echo $_SERVER['PHPSELF']; ?>" >
<input type="hidden" name="emailTo" value="mst0ke@yahoo.com" />
<p> </p>
<div id="title">CLASS SIGN UP </div>
<div class="row">
<label class="col1">Full Name: </label>
<span class="col2"><input name="name" class="input" type="text" id="name" size="20" tabindex="1" /></span>
</div>
<div class="row">
<label class="col1">Address: </label>
<span class="col2">
<input name="address" class="input" type="text" id="address" size="25" tabindex="2" />
</span>
</div>
<div class="row"><label class="col1">City: </label>
<span class="col2"><input name="city" class="input" type="text" id="city" value="" size="2" tabindex="3" /></span>
</div>
<div class="row"><label class="col1">State: </label>
<span class="col2"><input name="state" class="input" type="text" id="state" value="" size="9" tabindex="4" /></span>
</div>
<div class="row"><label class="col1">Age: </label>
<span class="col2"><input name="age" class="input" type="text" id="age" value="" size="3" tabindex="5" /></span>
</div>
<div class="row"></div>
<div class="row"><label class="col1comment">Comment: </label>
<span class="col2comment"><textarea cols="20" class="textarea" rows="4" name="comment" id="comment" tabindex="6" ></textarea></span>
</div>
<div align="center" class="submit">
<input type="submit" name="emailSubmit" value="Submit" />
</form>
</div>
<?php } ?>