forms mcqs.
Which HTML tag is used to create a form?
a) <input>
b) <form>
c) <div>
d) <body>
✅ Answer: b) <form>
Which attribute specifies where to send the form data when submitted?
a) method
b) action
c) target
d) href
✅ Answer: b) action
What does the method="get"
attribute in a form do?
a) Sends data using email
b) Sends form data in the request body
c) Appends form data to the URL
d) Encrypts form data
✅ Answer: c) Appends form data to the URL
How can you access a form value named “email” sent via the GET method in PHP?
a) $_POST["email"]
b) $_REQUEST["email"]
c) $_GET["email"]
d) $_FORM["email"]
✅ Answer: c) $_GET["email"]
Which PHP superglobal is used to collect form data sent with the GET method?
a) $GET[]
b) $_POST[]
c) $_FORM[]
d) $_GET[]
✅ Answer: d) $_GET[]
What is the correct input type to accept email in an HTML form?
a) type="text"
b) type="email"
c) type="mail"
d) type="submit"
✅ Answer: b) type="email"
Which tag is used to create a text input field in HTML?
a) <text>
b) <textbox>
c) <input>
d) <textarea>
✅ Answer: c) <input>
What will the following PHP code output if $_GET["name"] = "Alice"
?
echo "Welcome " . $_GET["name"];
a) Welcome b) Welcome name c) Welcome Alice d) Welcome $_GET[“name”] ✅ Answer: c) Welcome Alice
Where is the form data visible when using the GET method? a) In the PHP file b) In the source code c) In the HTTP header d) In the URL ✅ Answer: d) In the URL
What happens if a form does not have an action
attribute?
a) The form will not work
b) Data is sent to a default page
c) The page submits to itself
d) Form data is lost
✅ Answer: c) The page submits to itself