Thursday, 9 August 2018

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:
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”:
Above, we’ve set the target attribute to “_blank”, which means that it will now submit to a new tab or window.

0 comments:

Post a Comment