Over a million developers have joined DZone.

Submit Form Programmatically From PHP Using JavaScript

It´s something quite easy but may help a newby (as I´m now) in the future. 
This is a simple function in PHP to insert a JavaScript sentence which will do the same action as if the user would be pressing the Submit Button.
It can be used to use any control as a Submit Button or in case you make a form you need to send without interaction from the user.
the $FormName must be the name specified in the Form tag (i.e.: 
), if you didn´t specified any, you must now :) Lastly, just a tip regarding a trouble I had and may be you case too... if you have a form with all hidden fields, it won´t work, you have to have at least something echoed inside the form, just a letter can help, anyway, as it will redirect to the action URL, it should not be a problem as the form will disappear. function SubmitForm($FormName) //JavaScript function to submit a form programmatically //$FormName must be form´s name (as specified in the opening form tag) { echo ''; }

The best of DZone straight to your inbox.

Please provide a valid email address.

Thanks for subscribing!

Awesome! Check your inbox to verify your email so you can start receiving the latest in tech news and resources.

{{ parent.title || parent.header.title}}

{{ parent.tldr }}

{{ parent.urlSource.name }}