It's easier if you break it down into sections. I tend to build the form and the sending part all on one page but you could also do it with multiple pages each doing part of the process. I'll outline how i'd do it all on one page.
check if form submitted -> form not submitted so show form -> form filled and submitted -> page reloads and checks the form is submitted -> validate variables -> if good send email - > display success message on page.
This assumes there are no validation problems. If there are we will want to kick the user back to the form and show which bit is wrong.
My page has the check for submission, sending code and success message at the top and the form below. The form is turned off or on by checking a variable that is set in the validation process as in previous post.
Hope that makes sense and is useful.