I have a form like this
I know that this is an old question, but I found a different way to redirect after submitting a form.
First of all, to reiterate the basics of the tag since the OP was literally a NewUser, submitting a form has redirecting built into it. If you change your original html from:
to:
then clicking on your submit will automatically redirect you.
However, maybe NewUser wants submitting the form to always stay on www.example.com and only sometimes redirect to www.page-2.com, once the submission is complete? I ran into this exact scenario at work today.
In my case, we had a form that consisted of data in a table. Users could make changes to the data and then click the submit button (called "Save") to save the changes in the database. The action of just refreshed the form/table page because we wanted users to stay on that page.
We also had a link on that page that would take you to another page, but I had to make sure that it autosaved all the data before redirecting. So I made the link submit the form, and then redirect. This was accomplished with jQuery, and without Ajax. Here it is, adapted to NewUser's code:
( is unchanged, action="http://www.example.com")
(Note: be sure this bit of JavaScript is located at the very bottom of the php file, once everything else is loaded)