views:

30

answers:

1

Trying to detect when a user clicks "Cancel" but the $_POST on using var_export($_POST) outputs:-

array (
  'descr' => '',
  'formSubmitted' => '1',
  'backButton_x' => '36',
  'backButton_y' => '15',
)
Notice: Undefined index:  backButton in /home/mholt/development/BusinessPortico/class/requestHandler.class.php on line 81

Here is the HTML:-

<form method="post" class="cssform_dialog" enctype="multipart/form-data">
    <div id="dialogContent"></div> 
    <div id="dialogFooter">
    <div class="wrapperLeft"><input type="image" name="nextButton" id="nextButton" value="Yes" src="../new_assets/images/button-save.jpg"/></div>
    <div class="wrapperRight"><input value="Cancel" name="backButton" type="image" src="../new_assets/images/button-cancel.jpg"/></div>
    <input type="hidden" name="formSubmitted" value="1"/>
    </div>      
</form>
+2  A: 

Because it is type='image' — a server side image map.

A strict reading of the specification suggests that browsers should include the value for it, but not all do, so some just send the co-ordinates.

You can look for name.x (or name_x in PHP), or not use an image input in a way it wasn't designed for.

David Dorward
I don't understand because I have it working in other instances. How can I used Php to detect that the 'backButton' has been pressed?E.g. if($_POST['backButton'])) //do something