One form, one button, multiple actions

I have a form. When the user clicks “Submit,” I need the form posted to one URL, and email sent to an administrator, and the user’s browser redirected to a confirmation page. I have no idea how to do this. is PHP or javascript best?

The best is to use PHP.

JavaScript aint going to be able to send emails, so PHP is your tool.

Something like this:


if(isset($_POST['my_button'])) {
  mail('admin@example.com', 'Form Submitted', "Hello Admin.\\r\
Your form was submitted");

  header("Location: http://example.com/success.html");
  exit;
}


<form method="post" action="my_script.php">
<input type="submit" name="my_button" value="Submit">
</form>

thank you. I’ll try.