Html Forms Handling — Part 1 MCQs with Explanations
Practice high-yield Programming & Software Development MCQs on Html Forms Handling — Part 1 with worked academic solutions for FPSC, PPSC, NTS, NITB, PTS.
Questions
40
Difficulty Level
Exam-Level
Target Exams
FPSC, PPSC, NTS...
Estimated Time
48 mins
Exam-Level FPSC PPSC NTS NITB PTS
Verified for Commission Syllabus • Oct 14, 2026
40
Verified Practice Questions
Interactive test mode with detailed academic worked solutions
Live Progress|0/40 answered
✓0 correct
✗0 wrong
0% score
🎉 Set complete! All 40 questions answered.
Question 1 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
When you use the $_POST variable to collect data, the data is visible to.
Correct Answer: Option B — only you
Detailed Academic Explanation:
The POST method, data is invisible to others.
💡Key Conceptual Anchor:Html Forms Handling
Question 2 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
Which one of the following should not be used while sending passwords or other sensitive information?
Correct Answer: Option A — GET
Detailed Academic Explanation:
Because the data is visible to everyone.
💡Key Conceptual Anchor:Html Forms Handling
Question 3 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
What will be the value of the variable $input in the following PHP code? <?php $input = "Swapna<td>Lawrence</td>you are really<i>pretty</i>!" ; $input = strip_tags ($input, "<i></i>" ); ?>
Correct Answer: Option C — Swapna Lawrence you are reallypretty!
Detailed Academic Explanation:
Italic tags <i></i> might be allowable, but table tags <td></td> could potentially wreak havoc on a page.
💡Key Conceptual Anchor:Html Forms Handling
Question 4 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
How many validation filters like FILTER_VALIDATE_EMAIL are currently available?
Correct Answer: Option C — 7
Detailed Academic Explanation:
There are seven validation filters. They are FILTER_VALIDATE_EMAIL, FILTER_VALIDATE_BOOLEAN, FILTER_VALIDATE_FLOAT, FILTER_VALIDATE_INT, FILTER_VALIDATE_IP, FILTER_VALIDATE_REGEXP, FILTER_VALIDATE_URL.
💡Key Conceptual Anchor:Html Forms Handling
Question 5 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
Which of the following variables does PHP use to authenticate a user? 1. $_SERVER[‘PHP_AUTH_USER’]. 2. $_SERVER[‘PHP_AUTH_USERS’]. 3. $_SERVER[‘PHP_AUTH_PU’]. 4. $_SERVER[‘PHP_AUTH_PW’].
Correct Answer: Option C — 1 and 4
Detailed Academic Explanation:
$_SERVER[‘PHP_AUTH_USER’] and $_SERVER[‘PHP_AUTH_PW’] store the username and password values, respectively.
💡Key Conceptual Anchor:Html Forms Handling
Question 6 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
Which function is used to verify whether a variable contains a value?
Correct Answer: Option D — isset()
Detailed Academic Explanation:
The isset() function determines whether a variable has been assigned a value. Its prototype follows: boolean isset(mixed var [,mixed var [,…]]).
💡Key Conceptual Anchor:Html Forms Handling
Question 7 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
In which authentication method does changing the username or password can be done only by entering the code and making the manual adjustment.
Correct Answer: Option A — Hard-coding a login pair directly into the script
Detailed Academic Explanation:
This is one of the drawbacks of Hard-coding a login pair directly into the script.
💡Key Conceptual Anchor:Html Forms Handling
Question 8 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
The authentication File.txt, the file which stores username and password should be stored ________ the server document root.
Correct Answer: Option B — Outside
Detailed Academic Explanation:
f it is not stored outside, the attacker could discover the file through brute force guessing.
💡Key Conceptual Anchor:Html Forms Handling
Question 9 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
Which function is used to split a string into a series of substrings, with each string boundary is determined by a specific separator?
Correct Answer: Option C — explode()
Detailed Academic Explanation:
Although they are similar function, you should use explode() instead of split().In fact split() function has been deprecated altogether.
💡Key Conceptual Anchor:Html Forms Handling
Question 10 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
In which of the following situations does file-based authentication become inconvenient. 1. small list 2. large number of user 3. users are being regularly added 4. static authentication
Correct Answer: Option C — 2 and 3
Detailed Academic Explanation:
Such requirements are better satisfied by implementing a database based solution.
💡Key Conceptual Anchor:Html Forms Handling
Question 11 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
Which is the most powerful authentication method among the four?
Correct Answer: Option C — Data-based authentication
Detailed Academic Explanation:
It not only enhances administrative convenience and scalability, but also can be integrated into a larger database infrastructure.
💡Key Conceptual Anchor:Html Forms Handling
Question 12 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
Which directive determines whether PHP scripts on the server can accept file uploads?
Correct Answer: Option A — file_uploads
Detailed Academic Explanation:
By default its value is on.
💡Key Conceptual Anchor:Html Forms Handling
Question 13 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
Which of the following directive determines the maximum amount of time that a PHP script will spend attempting to parse input before registering a fatal error?
Correct Answer: Option C — max_input_time
Detailed Academic Explanation:
This is relevant because particularly large files can take some time to upload, eclipsing the time set by this directive.
💡Key Conceptual Anchor:Html Forms Handling
Question 14 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
Since which version of PHP was the directive max_file_limit available.
Correct Answer: Option C — PHP 5.2.12
Detailed Academic Explanation:
The max_file_limit directive sets an upper limit on the number of files which can be simultaneously uploaded.
💡Key Conceptual Anchor:Html Forms Handling
Question 15 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
Which directive sets a maximum allowable amount of memory in megabytes that a script can allow?
Correct Answer: Option D — memory_limit
Detailed Academic Explanation:
Its default value is 16M.
💡Key Conceptual Anchor:Html Forms Handling
Question 16 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
How many items are available in the $_FILES array?
Correct Answer: Option D — 5
Detailed Academic Explanation:
$_FILEs[‘userfile’][‘error’], $_FILEs[‘userfile’][‘name’], $_FILEs[‘userfile’][‘size’], $_FILEs[‘userfile’][‘tmp_name’], $_FILEs[‘userfile’][‘type’] are the five items in the array.
💡Key Conceptual Anchor:Html Forms Handling
Question 17 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
How many ways can a session data be stored?
Correct Answer: Option B — 4
Detailed Academic Explanation:
Within flat files(files), within volatile memory(mm), using the SQLite database(sqlite), or through user defined functions(user).
💡Key Conceptual Anchor:Html Forms Handling
Question 18 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
Which directive determines how the session information will be stored?
Correct Answer: Option D — session.save_handler
Detailed Academic Explanation:
Its prototype follows: session.save_handler = files|mm|sqlite|user.
💡Key Conceptual Anchor:Html Forms Handling
Question 19 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
Which one of the following is the default PHP session name?
Correct Answer: Option A — PHPSESSID
Detailed Academic Explanation:
You can change this name by using the session.name directive.
💡Key Conceptual Anchor:Html Forms Handling
Question 20 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
If the directive session.cookie_lifetime is set to 3600, the cookie will live until.
Correct Answer: Option A — 3600 sec
Detailed Academic Explanation:
The lifetime is specified in seconds, so if the cookie should live 1 hour, this directive should be set to 3600.
💡Key Conceptual Anchor:Html Forms Handling
Question 21 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
Neglecting to set which of the following cookie will result in the cookie’s domain being set to the host name of the server which generated it.
Correct Answer: Option D — session.cookie_domain
Detailed Academic Explanation:
The directive session.cookie_domain determines the domain for which the cookie is valid.
💡Key Conceptual Anchor:Html Forms Handling
Question 22 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
What is the default number of seconds that cached session pages are made available before the new pages are created?
Correct Answer: Option B — 180
Detailed Academic Explanation:
The directive which determines this is session.cache_expire.
💡Key Conceptual Anchor:Html Forms Handling
Question 23 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
What is the default time(in seconds) for which session data is considered valid?
Correct Answer: Option C — 1440
Detailed Academic Explanation:
The session.gc_maxlifetime directive determines this duration. It can be set to any required value.
💡Key Conceptual Anchor:Html Forms Handling
Question 24 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
Which function is used to erase all session variables stored in the current session?
Correct Answer: Option D — session_unset()
Detailed Academic Explanation:
This will not completely remove the session from the storage mechanism. If you want to completely destroy the session, you need to use the function session_destroy().
💡Key Conceptual Anchor:Html Forms Handling
Question 25 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
Which one of the following statements should you use to set the session username to Nachi?
Correct Answer: Option B — $_SESSION[‘username’] = “Nachi”
Detailed Academic Explanation:
You need to refer the session variable ‘username’ in the context of the $_SESSION superglobal.
💡Key Conceptual Anchor:Html Forms Handling
Question 26 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
What will be the output of the following PHP code? Say your previous session username was nachi. <?php unset ( $_SESSION [ 'username' ]); printf ( "Username now set to: %s" , $_SESSION [ 'username' ]); ?>
Correct Answer: Option C — Username now set to:
Detailed Academic Explanation:
To delete the session variable ‘username’ we use the unset() function.
💡Key Conceptual Anchor:Html Forms Handling
Question 27 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
An attacker somehow obtains an unsuspecting user’s SID and then using it to impersonate the user inorder to gain potentially sensitive information. This attack is known as.
Correct Answer: Option A — session-fixation
Detailed Academic Explanation:
You can minimize this risk by regenerating the session ID on each request while maintaining the session-specified data. PHP offers a convenient function named session_regenerate_id() that will replace the existing ID with a new one.
💡Key Conceptual Anchor:Html Forms Handling
Question 28 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
Which parameter determines whether the old session file will also be deleted when the session ID is regenerated?
Correct Answer: Option B — delete_old_session
Detailed Academic Explanation:
By default, this behavior is disabled.
💡Key Conceptual Anchor:Html Forms Handling
Question 29 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
The session_start() function must appear.
Correct Answer: Option D — before the html tag
Detailed Academic Explanation:
Like this:
💡Key Conceptual Anchor:Html Forms Handling
Question 30 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
What is the return type of session_set_save_handler() function?
Correct Answer: Option A — boolean
Detailed Academic Explanation:
Returns TRUE on success or FALSE on failure.
💡Key Conceptual Anchor:Html Forms Handling
Question 31 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
Before you can start processing images with PHP, you must first add the ability to upload images to your administrative form on ________
Correct Answer: Option D — admin.php
Detailed Academic Explanation:
To do this, you’ need to add a file upload input to your administrative form.
💡Key Conceptual Anchor:Html Forms Handling
Question 32 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
When you’re uploading files you need to set the enctype of the form to __________
Correct Answer: Option C — multipart/form-data
Detailed Academic Explanation:
Set the enctype of the form to multipart/form-data, which can accept files and standard form values.
💡Key Conceptual Anchor:Html Forms Handling
Question 33 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
To check whether a file was uploaded, you look in the _______ superglobal array.
Correct Answer: Option A — $_FILES
Detailed Academic Explanation:
Whenever a file is uploaded via an HTML form, that file is stored in temporary memory and information about the file is passed in the $_FILES superglobal.
💡Key Conceptual Anchor:Html Forms Handling
Question 34 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
To make the ImageHandler class portable you should create a separate file for it called __________
Correct Answer: Option B — images.inc.php
Detailed Academic Explanation:
You save this file in the inc folder (full path: /xampp/htdocs/simple_blog/inc/images.inc.php).
💡Key Conceptual Anchor:Html Forms Handling
Question 35 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
DocBlocks are indicated by opening a comment using _________
Correct Answer: Option C — /**
Detailed Academic Explanation:
This is a special comment that provides information about a class, property, or method.
💡Key Conceptual Anchor:Html Forms Handling
Question 36 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
To process the file, you need to break the array from $_FILES into individual values. You can do this using the ________ function.
Correct Answer: Option B — list()
Detailed Academic Explanation:
The list() function allows you to create named variables for each array index as a comma-separated list.
💡Key Conceptual Anchor:Html Forms Handling
Question 37 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
Before you try to process the file, you need to make sure that your $err value is equivalent to _________
Correct Answer: Option A — UPLOAD_ERR_OK
Detailed Academic Explanation:
When you’re dealing with files uploaded through an HTML form, you have access to a special constant called UPLOAD_ERR_OK that tells you whether a file uploaded successfully.
💡Key Conceptual Anchor:Html Forms Handling
Question 38 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
You use the $_SERVER superglobal and your _______ property to create your path to check.
Correct Answer: Option D — $save_dir
Detailed Academic Explanation:
// Determines the path to check $path = $_SERVER[‘DOCUMENT_ROOT’] . $this->save_dir;
💡Key Conceptual Anchor:Html Forms Handling
Question 39 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
Which function do you have to use to check whether the $path you’ve stored exists?
Correct Answer: Option C — is_dir()
Detailed Academic Explanation:
If the path exists, is_dir() returns TRUE; otherwise, it returns FALSE.
💡Key Conceptual Anchor:Html Forms Handling
Question 40 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
Which one of the following is true about the following line – $obj = new ImageHandler(‘/images/’, array(400, 300));
Correct Answer: Option A — This snippet sets the maximum dimensions allowed to 400 pixels wide by 300 pixels high
Detailed Academic Explanation:
If you needed to change the size of your images, you can change the dimensions using the above instantiation of ImageHandler
💡Key Conceptual Anchor:Html Forms Handling
✓Link copied to clipboard
Continue Your Practice
Advance Html — Part 1
Master the next curriculum module with 40 exam-standard MCQs.
💡Examiner's Advisory for Programming & Software Development
In competitive commission exams (FPSC, PPSC, KPPSC, SPSC, CSS, PMS), questions are frequently phrased with distractor options designed to catch rote learners. Whenever you answer an MCQ, read the Detailed Academic Explanation and Conceptual Anchor to understand why the remaining options are incorrect.