0% found this document useful (0 votes)
3 views

PHP_Assignmnet-4

The document is an assignment for a PHP and MySQL course at Ganpat University, containing multiple-choice questions (MCQs) and long answer questions related to form handling in PHP. It covers topics such as methods for sending sensitive data, superglobal arrays, form input attributes, and security practices against XSS attacks. Additionally, it includes tasks for explaining form attributes, input controls, and writing a PHP script for student registration.

Uploaded by

jayeshpatel8144
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
3 views

PHP_Assignmnet-4

The document is an assignment for a PHP and MySQL course at Ganpat University, containing multiple-choice questions (MCQs) and long answer questions related to form handling in PHP. It covers topics such as methods for sending sensitive data, superglobal arrays, form input attributes, and security practices against XSS attacks. Additionally, it includes tasks for explaining form attributes, input controls, and writing a PHP script for student registration.

Uploaded by

jayeshpatel8144
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 3

GANPAT UNIVERSITY, KHERVA

BSPP/IOT, COMPUTER ENGINEERING DEPARTMENT


ASSIGNMENT-4
PHP & MySQL (1IT2402)
MCQ
1. What method should be used to send sensitive data in a form?
A) GET B) POST C) DELETE D) PUT

2. Which superglobal array in PHP contains information about headers, paths,


and script locations?
A) $_GET B) $_POST C) $_SERVER D) $_FILES

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'];
}
?>

A) Incorrect use of $_GET and $_POST


B) No issue
C) Syntax error
D) The input name should be 'submit' instead of 'name'

11.Spot the error in the following PHP form handling code:


if ($_SERVER ['REQUEST_METHOD'] == 'POST') {
echo $_POST [name];
}
?>
A) Missing quotes around array key name
B) No error in the code
C) Syntax error in if statement
D) Missing semicolon in echo statement
Long Questions

1. Explain any three attributes of form in php.


2. Explain any four input controls of form tag.
3. Give the difference between GET and POST method.
4. Write a PHP script to create student registration form and display
content on the different page. (Use $_POST or $_REQUEST).
5. Explain use of query string with example in PHP.

You might also like