Form Names

Given the following page:

<form>
  <input type="radio" name="BT.123" value="active" />
  <input type="radio" name="BT.123" value="inactive" />
  <input type="submit" value="Submit" />
</form>

<?php
  echo "GET: ", $_GET['BT.123'];
  echo "POST: ", $_POST['BT.123'];
  echo "REQUEST: ", $_REQUEST['BT.123'];
?>

Assume the “inactive” button is checked and the form is submitted. What is the output?
Answer: Because the “.” is converted to “_”, only the string literals (and some warnings, if using E_STRICT) are output.

GET: 
POST:
REQUEST:

In other words, use $_REQUEST[‘BT_123’] instead.

Comments

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.