I have a form
<form method='post' action='action.php' name='myForm'>
<input type='' name='id' value='id'>
<script>document.myForm.submit();</script>
</form>
Can I submit this form without using JavaScript - only PHP without clicking on the submit button, automatically?
This form must be auto submitted on page load, but not using JavaScript (without onload
)
A form must be submit, by the client side. On client-side, there's only two way: by Javascript or by human (clicking on the submit button).
Unfortunately, what you are trying to do is not possible. The best you can do is probably this:
A submit button is displayed when client side scripting is disabled. When it's enabled, the submit button is immediately hidden and the form is automatically submitted.
EDIT
Or you could simply include the PHP file.
<?php include action.php; ?>
. You won't have access to the_POST
array, but considering, the client hasn't had chance to enter any data, that won't really matter.The act of form submission is done on the client side (browser) and has very little to do with PHP (server side).
You could add a submit button like
<input type='submit' value='click here to complete step' />
Why not just use the
<input type="submit" />
like the following:add a submit button.