Skip to content
PHP Logo

Are there any specific considerations to keep in mind when using <input type="image"> in PHP forms?

When using <input type="image"> in PHP forms, it's important to remember that the value of the input will be sent as coordinates (x and y) of the click position on the image, rather than a traditional value like with other input types. To handle this in PHP, you can check for the presence of these coordinates in the $_POST superglobal array and process them accordingly.

php
if(isset($_POST['submit_x']) && isset($_POST['submit_y'])) {
    $x = $_POST['submit_x'];
    $y = $_POST['submit_y'];
    
    // Process the coordinates as needed
}