Submit PHP form to new tab / page.

This is a short and sweet tutorial on how to submit a PHP form (or any HTML form, for that matter) to a new tab using HTML’s target attribute.

Take a look at the following HTML form:

<form method="post" action="process-form.php">
    <input type="text" name="email_address" /><br>
    <input type="submit">
</form>

The form above is pretty simple:

  • We’ve set the method attribute to POST.
  • The form will be submitting to a PHP page called process-form.php (specified in the action attribute).
  • There is a simple text field called “email_address” and a submit button.

When you press the submit button, this form will go to “process-form.php” in the same tab / window that you’re currently in. This is because, by default, the target attribute for links and forms is always set to “_self”. If you want it to submit to a new tab instead of the current one, then you will need to add the target attribute to the form tag and change it to “_blank”:

<!-- adding target="_blank" to our form tag -->
<form method="post" action="process-form.php" target="_blank">

Above, we’ve set the target attribute to “_blank”, which means that it will now submit to a new tab or window.