Why so complicated? Perhaps there is a better way, but here is what I would do.
- Page with form
- When the user submits the form, check to make sure all fields have been completed and that they fit the parameters.
- Write the data to your database.
- Use a simple email script to send your email.
$aemailsubject = "Subject Line goes here";
$aemailbody = "
A bug report was submitted:
Name: ".$POST[name]."
Item 2: ".$POST[item2]."
Email: ".$POST[email]."
Item 3: ".$POST[item3]."
This email should be entered as a ticket using the name and email above and with a category of Fundraising Network.";
$aemailto = "destination email address";
$aemailfrom = $POST[email];
$aemailreply = $POST[email];
mail($aemailto, $aemailsubject, $aemailbody, "From:".$aemailfrom."\nReply-To:".$aemailreply."\n");
If certain fields have to be filled out a certain way, such as a certain field not exceeding a certain length, do the check at step 2 and return them to the form. That way, you don't rewrite the email portion of the script over and over. The email doesn't send until everything is ready.
Mr. Grammar