0

I am just trying to figure out why even though i have a value selected, my isset is pulling through that there is no data selected.

The HTML:

<form action="submitBackgroundImage.php" id="submitBackground">
      <input type="radio" name="background" value="lake" checked="checked"> Lake.jpg<br>
      <input type="radio" name="background" value="dock"> Dock.jpg<br>
      <input type="radio" name="background" value="forest"> Forest.jpg<br>
      <button type="submit" form="submitBackground" value="Submit">Submit</button>
</form>

The PHP in "submitBackgroundImage.php":

<?php

if (isset($_POST['background'])) {
    echo "Data Selected";
}
else
{
    echo "No Data Selected";
};

?>

This returns:

enter image description here

I'm a PHP novice so any advice is appreciated.

Luke Litherland
  • 217
  • 4
  • 16

2 Answers2

3

You're missing the method.

<form action="submitBackgroundImage.php" id="submitBackground" method="POST">
maio290
  • 6,440
  • 1
  • 21
  • 38
0

Define the method in form element so that you will get the data when you submit the form

<form action="submitBackgroundImage.php" method="POST" id="submitBackground">
      <input type="radio" name="background" value="lake" checked="checked"> Lake.jpg<br>
      <input type="radio" name="background" value="dock"> Dock.jpg<br>
      <input type="radio" name="background" value="forest"> Forest.jpg<br>
      <button type="submit" form="submitBackground" value="Submit">Submit</button>
</form>
Exterminator
  • 1,221
  • 7
  • 14