PHP_Assignmnet-4
PHP_Assignmnet-4
3. In a form, to group multiple elements that belong together, which HTML tag
is used?
A) < group > B) < fieldset > C) < section > D) < div >
4. How do you access form data sent via the GET method in PHP?
A) Using the $_REQUEST superglobal
B) Using the $_GET superglobal
C) Using the $_POST superglobal
D) Using the $_SERVER superglobal
5. What is the correct way to check if a form has been submitted in PHP?
A) Checking if $_POST is set
B) Checking if $_GET is set
C) Checking if $_SERVER['REQUEST_METHOD'] is POST
D) Checking if $_REQUEST is set
6. Which attribute in a form input element specifies the field's initial value?
A) value B) type C) name D) placeholder
7. Given a form with method="post", which PHP array will contain the form's
submitted data?
A) $_GET B) $_POST C) $_REQUEST D) $_SERVER
8. What will be the output of the following PHP code if a user submits a form
with an input named email?
if (isset($_POST['email'])) {
echo $_POST['email'];
}
?>
A) The value of the email input field
B) NULL
C) An empty string
D) An error message
9. In PHP, how do you securely access a form value sent via POST to prevent
XSS attacks?
A) Using htmlspecialchars($_POST['value'])
B) Using $_POST['value'] directly
C) Using strip_tags($_POST['value'])
D) Using mysqli_real_escape_string($_POST['value'])
10.Identify the issue in this PHP code for handling a form input:
if (isset($_GET['submit'])) {
echo $_POST['name'];
}
?>