separate each piece out into functions and then just call the functions
if ($_POST['submit']){ //check to see if the submit was hit
//if not then show the form
show_form();
}else{
//send email
do_email();
//send data to database
do_db_stuff();
}
function show_form()
{
//code for form goes here
}
function do_email()
{
//code for email goes here
mail ($to, $subject, $body, $from);
}
function do_db_stuff()
{
//database load goes here
}