{
  "id": "08",
  "content": [
    {
      "type": "heading",
      "text": "Forms, $_GET, $_POST & Filtering"
    },
    {
      "type": "text",
      "html": "Read form data via superglobals <code>$_GET</code> and <code>$_POST</code>. Always validate and sanitize input."
    },
    {
      "type": "text",
      "html": "<pre><code>&lt;form method=\"post\"&gt;\n  &lt;input name=\"email\"&gt;\n  &lt;button&gt;Send&lt;/button&gt;\n&lt;/form&gt;\n\n&lt;?php\n$email = filter_input(INPUT_POST, 'email', FILTER_VALIDATE_EMAIL);\nif ($email) { echo 'Thanks!'; } else { echo 'Invalid email'; }\n</code></pre>"
    },
    {
      "type": "text",
      "html": "Use <code>filter_input</code> and prepared statements to avoid injection."
    }
  ],
  "quiz": {
    "questions": [
      {
        "id": "q1",
        "type": "single",
        "text": "Which superglobal reads POST data?",
        "options": [
          {
            "id": "a",
            "text": "$_POST"
          },
          {
            "id": "b",
            "text": "$_GET"
          },
          {
            "id": "c",
            "text": "$_COOKIE"
          }
        ],
        "correct": [
          "a"
        ]
      },
      {
        "id": "q2",
        "type": "single",
        "text": "Which function helps validate input like email?",
        "options": [
          {
            "id": "a",
            "text": "filter_input"
          },
          {
            "id": "b",
            "text": "validate()"
          },
          {
            "id": "c",
            "text": "html_email()"
          }
        ],
        "correct": [
          "a"
        ]
      }
    ]
  }
}