run $self to send details to DB and run mymail.php to send out an e-mail.
So you want to send the form results to the same page and then send the data to mymail.php. E.g., if the page with the form were called form.php, you'd want to send the form results to form.php and then mymail.php. Is this correct?
If which case, all you'd have to do would be to include these lines at the bottom of (e.g.) form.php:
-
if(/* some kind of validation check to make sure $_POST is valid> */)
-
include('mymail.php');
-
By including mymail.php directly in your form page, you are giving it access to the POST variables available to your form page.
As a general rule, I've found that it's not a good idea to submit form values to the same page as the form (what if the User refreshes the page?).
The way I would handle it would be to have the form send its values to a separate page that validates and saves the data into the session, then redirects back to the form page if further information/action is necessary, or else calls the mailer script and then redirects to a 'success' page when finished.