If I submit forms without input(type="submit") and I use a href with javascript, like this:
<a href="javascript:document.form-name.submit();" rel="nofollow">Button</a>
Is a way to check with php what form is submitted? (with input, I use if (isset($_POST['input-name'])))
asked Jun 21, 2011 at 17:28
user523196
3 Answers 3
Include a hidden field in your form that contains the form identification data you desire.
answered Jun 21, 2011 at 17:31
George Cummins
29k8 gold badges74 silver badges91 bronze badges
Sign up to request clarification or add additional context in comments.
Comments
Just use this temporarily to understand what PHP is receiving from the POST array.
var_dump($_POST);
answered Jun 21, 2011 at 17:32
Cups
6,9063 gold badges29 silver badges30 bronze badges
Comments
Natively? Not through JS. You'll need to modify the values which are sent. There are a couple of ways to do that:
- Change the action:
<form action="/processor.php?input-name=INPUT!">Then get the value from $_GET in PHP (warning, this will not work if the request is a get request). - Add a hidden input:
<input type="hidden" name="input-name" value="INPUT!" />The value will now be part of either $_GET or $_POST, depending on the action of the form.
answered Jun 21, 2011 at 17:33
cwallenpoole
82.4k26 gold badges132 silver badges174 bronze badges
Comments
lang-php
Java is to JavaScript like Car is to Carpet.