0

I have a PHP script which is getting input from an HTML form. The inputs are images. I've just found out it is broken in Internet Explorer (using v11). This thread (input type=image name and value not being sent by ie and opera) and the HTML spec say that x and y values are being sent, and the solution is to query name.x or name.y to find out if they are empty. However, this isn't working for me in IE and has also broken the script in Chrome - they still don't see a filled input variable. What am I doing wrong?

Form:

<form action="<?php echo htmlspecialchars($_SERVER["PHP_SELF"]);?>" method="post">
<input type="image" name="newssource_guardian" value="guardian" alt="The Guardian masthead" src="guardian.png">
<input type="image" name="newssource_BBCnews" value="BBCnews" alt="BBC news icon" src="bbcnews.png" class="w3-round w3-margin-bottom" style="width:95%">
<input type="image" name="newssource_dailymail" value="dailymail" alt="Mail Online icon" src="mail.jpg" class="w3-round w3-margin-bottom" style="width:95%">
</form>

Dealing with the input:

<?php
if ($_SERVER["REQUEST_METHOD"] == "POST") 
{
if ((!empty($_POST["newssource_guardian.x"]) and $_SESSION['newsource']=="guardian") 
or (!empty($_POST["newssource_BBCnews.x"]) and $_SESSION['newsource']=="BBCnews")
or (!empty($_POST["newssource_dailymail.x"]) and $_SESSION['newsource']=="dailymail"))
    {
//bla bla bla
}
}
?>
icw
  • 1
  • 2

1 Answers1

0

OK, the answer turns out to be that you have to query

$_POST["newssource_guardian_x"]

(not $_POST["newssource_guardian.x"])

I didn't know PHP did this. var_dump($_POST) was helpful in working it out.

icw
  • 1
  • 2