NEW
Font size
WorksheetsPHP Form
Total questions: 20
Worksheet time: 10mins
What does PHP stand for?
Hypertext Preprocessor
Preprocessor Hypertext
Personal Home Page
Programming Hypertext Pages
Portable Hypertext Processor
Which method is used to retrieve variables from a URL in PHP?
$_GET
$_POST
$_REQUEST
$_COOKIE
$_SESSION
What is the main security risk when using the $_GET method to retrieve data?
HTML or JavaScript injection
SQL injection
Cross-site request forgery (CSRF)
Password brute forcing
Data leakage in browser history
Which PHP function is used to convert special characters into HTML entities to prevent security issues?
htmlspecialchars()
htmlentities()
strip_tags()
urlencode()
addslashes()
Which HTTP method should be used when submitting sensitive data, such as passwords, to a server?
POST
GET
PUT
DELETE
CONNECT
Which of the following is NOT a difference between GET and POST methods?
GET appends data to the URL, while POST sends data in the HTTP body.
GET is more secure than POST for sending sensitive data.
POST does not append data to the URL.
GET is limited by URL length, POST is not.
GET requests can be bookmarked, POST requests cannot.
What is the purpose of the $_REQUEST array in PHP?
To collect values from both GET and POST methods
To manage session data
To track cookies
To access files uploaded through forms
To store form validation errors
What is the purpose of the ‘action’ attribute in an HTML form?
Specifies where to send the form data upon submission
Specifies the HTTP method to use (GET or POST)
Specifies the input elements to include in the form
Specifies the type of encoding for the form data
Specifies the server to receive the form data
What does the htmlspecialchars() function do when handling form data?
Converts special HTML characters to prevent XSS attacks
Encrypts form data
Strips HTML tags from the input
Validates form input for correctness
Converts form data into JSON format
Which statement about POST method is true?
It submits data in the HTTP message body.
It appends data to the URL.
It is limited to ASCII characters only.
It stores parameters in browser history.
It is always visible to everyone in the URL.
Which PHP superglobal is used to get the values submitted by a form using the POST method?
$_POST
$_GET
$_FILES
$_SESSION
$_COOKIE
What is the benefit of using PHP includes for separating HTML and PHP code?
Allows for cleaner and more maintainable code
Increases the execution speed of PHP scripts
Avoids database queries
Automatically sanitizes form data
Secures PHP code from public access
Which method should be avoided when submitting sensitive information such as passwords or credit card numbers?
GET
POST
PUT
DELETE
PATCH
Which of the following is a valid URL query string format for passing multiple variables?
name1=value1&name2=value2
name1,value1;name2,value2
name1:value1/name2:value2
name1-value1&name2-value2
name1/value1|name2/value2
What is the main advantage of using POST over GET when submitting form data?
POST does not expose form data in the URL.
POST can send more data.
POST is easier to debug.
POST supports only ASCII characters.
POST stores form data in browser history.
What PHP function checks whether a variable is set?
isset()
empty()
is_null()
define()
isset_value()
In PHP, how do you access multiple form variables sent via GET in the URL?
$_GET['var_name']
$_POST['var_name']
$_SERVER['var_name']
$_REQUEST['var_name']
$_SESSION['var_name']
What does the “Monokai” theme refer to in the context of PHP development?
A color scheme in VS Code
A PHP coding style guide
A database management tool
A web server configuration
A templating engine
What is the primary purpose of a PHP template file?
To insert dynamically generated content into an HTML structure
To handle form validation
To manage database queries
To configure server-side settings
To execute background PHP processes
What is the difference between $_GET and $_POST in PHP?
$_GET retrieves data from the URL, $_POST retrieves data from the body of the HTTP request.
$_GET retrieves data from cookies, $_POST retrieves data from sessions.
$_GET retrieves data from files, $_POST retrieves data from forms.
$_GET retrieves data from databases, $_POST retrieves data from APIs.
$_GET retrieves sensitive data, $_POST retrieves non-sensitive data.
