2

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)

cfedermann
  • 3,286
  • 19
  • 24
user1029691
  • 69
  • 1
  • 4

5 Answers5

4

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' />

ctrl-alt-dileep
  • 2,066
  • 1
  • 16
  • 14
4

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).

Nettogrof
  • 2,116
  • 2
  • 15
  • 22
  • php function are server-side ( before the web page send to user). Submitting a form, is done after the user receive the web page – Nettogrof Apr 16 '12 at 14:33
  • Maybe you shouldn't send this page to the user, redirect him to the other web page. – Nettogrof Apr 16 '12 at 14:34
  • this form include by iframe 1x1 px, they great work by using js, but i heed to do submit this form automatikly in browser without js and object(denied)-just only html and php – user1029691 Apr 16 '12 at 14:38
1

Why not just use the <input type="submit" /> like the following:

<form method='post' action='action.php' name='myForm'>
  <input type='text' name='id' value='id' />
  <input type='submit' name='submission' value='Submit id'>
</form>
hjpotter92
  • 78,589
  • 36
  • 144
  • 183
1

add a submit button.

<input type="submit" value="Submit" />
Rodik
  • 4,054
  • 26
  • 49
0

Unfortunately, what you are trying to do is not possible. The best you can do is probably this:

<form method='post' action='action.php' name='myForm'>
    <input type='' name='id' value='id'>
    <input type='submit' id='submit-button' />
    <script>domument.getElementByID('submit-button').style.display="none";document.myForm.submit();</script>
</form>

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.

Dan Bray
  • 7,242
  • 3
  • 52
  • 70