{
  "id": "07",
  "content": [
    {
      "type": "heading",
      "text": "Handling Forms (GET/POST) & Templating"
    },
    {
      "type": "text",
      "html": "Use <code>param()</code> to read GET/POST fields. Remember to output the correct header."
    },
    {
      "type": "text",
      "html": "<pre><code>use CGI qw(:standard);\nprint header('text/html');\nmy $email = param('email');\nprint start_html('Form'), h1('Thanks'), p(\"Email: $email\"), end_html;\n</code></pre>"
    },
    {
      "type": "text",
      "html": "For cleaner HTML, use templates (e.g., Template Toolkit) or simple heredocs."
    }
  ],
  "quiz": {
    "questions": [
      {
        "id": "q1",
        "type": "single",
        "text": "What must be printed before HTML in CGI?",
        "options": [
          {
            "id": "a",
            "text": "HTTP header (e.g., Content-Type) and a blank line"
          },
          {
            "id": "b",
            "text": "doctype only"
          },
          {
            "id": "c",
            "text": "nothing"
          }
        ],
        "correct": [
          "a"
        ]
      },
      {
        "id": "q2",
        "type": "single",
        "text": "A common module for CGI HTML helpers is:",
        "options": [
          {
            "id": "a",
            "text": "CGI.pm"
          },
          {
            "id": "b",
            "text": "Requests"
          },
          {
            "id": "c",
            "text": "LWP.js"
          }
        ],
        "correct": [
          "a"
        ]
      }
    ]
  }
}