Samacheer Kalvi 12th Computer Applications Solutions Chapter 8 Forms and Files

Students can Download Computer Applications Chapter 8 Forms and Files Questions and Answers, Notes Pdf, Samacheer Kalvi 12th Computer Applications Book Solutions Guide Pdf helps you to revise the complete Tamilnadu State Board New Syllabus and score more marks in your examinations.

Tamilnadu Samacheer Kalvi 12th Computer Applications Solutions Chapter 8 Forms and Files

Samacheer Kalvi 12th Computer Applications Forms and Files Text Book Back Questions and Answers

PART – I
I. Choose The Correct Answer

Question 1.
When you use the $_GET variable to collect data, the data is visible to..
(a) none
(b) only you
(c) everyone
(d) selected few
Answer:
(c) everyone

Samacheer Kalvi 12th Computer Applications Solutions Chapter 8 Forms and Files

Question 2.
Which one of the following should not be used while sending passwords or other sensitive information?
(a) GET
(b) POST
(c) REQUEST
(d) NEXT
Answer:
(a) GET

Question 3.
Which directive determines whether PHP scripts on the server can accept file uploads?
(a) file_uploads
(b) fileupload
(c) filejnput
(d) file_intake
Answer:
(a) file_uploads

Samacheer Kalvi 12th Computer Applications Solutions Chapter 8 Forms and Files

Question 4.
In HTML form <input type=”text”> is used for …………………………..
(a) One line text
(b) Block of text
(c) One paragraph
(d) None
Answer:
(a) One line text

Question 5.
HTML classes that is already defined and allow us to apply styles on it are called as ………………………….
(a) Pseudo classes
(b) Css classes
(c) Javascript classes
(d) Nre
Answer:
(b) Css classes

Samacheer Kalvi 12th Computer Applications Solutions Chapter 8 Forms and Files

Question 6.
If you would like to read a file character by character which function do you use?
(a) fopen( )
(b) fread( )
(c) fgetc( )
(d) fleo
Answer:
(c) fgetc( )

Question 7.
PHP is a ……………………….. typed language.
(a) User
(b) Loosely
(c) Server
(d) System
Answer:
(c) Server

Samacheer Kalvi 12th Computer Applications Solutions Chapter 8 Forms and Files

Question 8.
What does fopen( ) function do in PHP?
(a) It used to open files in PHP
(b) It used to open Remote Server
(c) It used to open folders in PI-IP
(d) It used to open Remote Computer
Answer:
(b) It used to open Remote Server

Question 9.
How PHP files can be accessed?
(a) Through Web Browser
(b) Through HTML files
(c) Through Web Server
(d) All of Above
Answer:
(d) All of Above

Samacheer Kalvi 12th Computer Applications Solutions Chapter 8 Forms and Files

Question 10.
Which of the following functions reads the entire contents of a file?
(a) fgets( )
(b) file_get_contents( )
(c) fread( )
(d) readfile( )
Answer:
(b) file_get_contents( )

PART – II
II. Short Answer

Question 1.
Define HTML form controls?
Answer:
Main objective of PHP and HTML form controls are to collect data from users. The various form controls are

  1. Text inputs
  2. Checkbox
  3. File Select
    • Buttons
    • Radio box
    • FormTag

Samacheer Kalvi 12th Computer Applications Solutions Chapter 8 Forms and Files

Question 2.
Define for Form Handling method in PHP?
Answer:

  1. Form tag is used to mention a method (POST or GET) and control the entire form controls in the HTML document.
  2. All input values are synchronized and sent to the server via POST or GET method.

Question 3.
What is Form Validation in PHP?
Answer:

  1. Validation is a process of checking the input data submitted by the user from client machine.
  2. There are two types of validation available in PHP. They are as follows, Client-Side Validation, Server Side Validation.

Samacheer Kalvi 12th Computer Applications Solutions Chapter 8 Forms and Files

Question 4.
List out HTML control to support PHP language?
Answer:
Basic HTML Form Controls
The following control types are available in HTML form controlling:

  1. Text inputs
  2. Checkbox
  3. File Select
  4. Buttons
  5. Radio box
  6. Form Tag

Text inputs contain textbox and text area controls. Buttons may contain Submit button, Reset button and Cancel Button.

Samacheer Kalvi 12th Computer Applications Solutions Chapter 8 Forms and Files

Question 5.
Write Syntax of Text box in HTML?
Answer:
Name: <input type-‘text” name=“name”><br>
E-mail: <input type=“texf ’ name=“email”><br>

Question 6.
Define File handling in PHP?
Answer:
Files
File handling is an important activity of all web application development process. Files are processed for different tasks using the following events:

  1. PHP Open a File
  2. PHP Read a File
  3. PHP Close a File
  4. PHP Write a File
  5. PHP Appending a File and
  6. PHP uploading a File.

Samacheer Kalvi 12th Computer Applications Solutions Chapter 8 Forms and Files

Question 7.
Define Browse button in HTML?
Answer:
Browse Button in HTML:

  1. In the <Input> tag mention type = “file” attribute shows the input field as a file-select control, with a “Browse” button next to the input control.
  2. Browse button is used to search for any file or websites.

Question 8.
Write Syntax of Browse button in HTML?
Answer:
Syntax:
<input type = file name = browse>

Samacheer Kalvi 12th Computer Applications Solutions Chapter 8 Forms and Files

Question 9.
Compare Text box and Text Area?
Answer:
Text Box:

  1. Text Box is a single line box
  2. Text boxes are generally used for collecting information such as names, email addresses.

Text Area:

  1. Text area is a multiple line box
  2. Text area’s are generally used to gather feedback or comments.
  3. It has a limit of 32700 characters.

Samacheer Kalvi 12th Computer Applications Solutions Chapter 8 Forms and Files

Question 10.
Usage of File open function?
Answer:

  1. fopen( ) is a system function available in PHP.
  2. This function helps to open a file in the server.
  3. It contains two parameters one for the file and the other one specifies in which mode the file should be opened (Read/Write).

PART – III
III. Explain in Brief Answer

Question 1.
Write the features Form Handling?
Answer:
Form Handling:

  1. Form controls are used to collect data from the users and sent to server.
  2. When the user keying the input data in HTML controls and clicks the submit button the request will be generated and reaches a PHP file which is mentioned in the FORM tag under the Action attribute.
  3. All input values are synchronized and sent to the server via POST method or GET method.
  4. Once the data reaches the server, two PHP variables such as $_POST and $_GET collects – the data and prepares the response accordingly.

Samacheer Kalvi 12th Computer Applications Solutions Chapter 8 Forms and Files

Question 2.
Write the purpose Get method and Post method?
Answer:
All input values are synchronized and sent to the server via POST method or GET method. Method is an attribute form tag in HTML. Once the data reaches the server, two PHP variables such as $_POST and $_GET collects the data and prepares the response accordingly.

Post Method:
The input data sent to the server with POST method is stored in the request body of the client’s HTTP request.

Get Method:
The input data sent to the server with POST method via URL address is known as query string. All input data are visible by user after they clicks the submit button.

Samacheer Kalvi 12th Computer Applications Solutions Chapter 8 Forms and Files

Question 3.
Differentiate Get and Post Method?
Answer:
Get Method:

  1. It is used to send data through URL address.
  2. All the input data are visible.
  3. It is faster.
  4. It is less secure.

Post Method:

  1. It is send through clients HTTP request.
  2. It is not visible.
  3. It is little slow.
  4. It is secured.

Samacheer Kalvi 12th Computer Applications Solutions Chapter 8 Forms and Files

Question 4.
Write short notes on File handling?
Answer:

  1. File handling is an important activity of all web application development process.
  2. Files are processed for different tasks using the following events:
    1. Opening a file
    2. Reading a file
    3. closing a file
    4. To write a file
    5. To append a file
    6. To upload a file

Samacheer Kalvi 12th Computer Applications Solutions Chapter 8 Forms and Files

Question 5.
Write short notes on File handling functions?
Answer:

  1. fopen( ) – PHP Open a File
  2. fread( ) – PHP Read a File,
  3. fclose( ) – PHP Close a File,
  4. fwrite( ) – PHP Write a File,
  5. file_put_contents( ) – PHP Appending a File

PART – IV
IV. Explain in detail

Question 1.
Explain Form Handling methods?
Answer:
PHP Basic Form Handling:

  1. When the user keying the input data in HTML controls and clicks the submit button the request will be generated and reaches a PHP file which is mentioned in the FORM tag under the Action attribute.
  2. All input values are synchronized and sent to the server via POST method or GET method.
  3. Method is an attribute form tag in HTML. Once the data reaches the server, two PHP variables such as $_POST and $_GET collects the data and prepares the response accordingly.

Post Method:
The input data sent to the server with POST method is stored in the request body of the client’s HTTP request.

Get Method:
The input data sent to the server with POST method via URL address is known as query string. All input data are visible by user after they clicks the submit button.
Example:
Test.html:
<htnjl>
<body>
<form action=“welcome.php” method=“posf’>
Name: <input type=“text” name=“name”><br>
E-mail: <input type=“text” name=“email”><br>
<input type=“submif’>
</form>
</body>
</html>
Welcome.php:
<html>
<body>
Welcome <?php echo $_POST[“name”]; ?><br>
Your email address is: <?php echo $_POST[“email”]; ?>
</body>
</html>
Samacheer Kalvi 12th Computer Applications Solutions Chapter 8 Forms and Files

  • HTML File contains two Text Box (Name and Email), One Button and one form tag. The remote server PHP file (welcome.php) is mentioned in form tag under the Action Attribute.
  • In “Welcome.Php” file, PHP variables such as $_POST and SGET collects the data and prepares the response accordingly.
  • Eventually the user will receive the output response in the client machine’s browser screen.

Samacheer Kalvi 12th Computer Applications Solutions Chapter 8 Forms and Files

Question 2.
Discuss in detail about HTML form controls?
Answer:
Basic HTML Form Controls
The following control types are available in HTML form controlling:

  1. Text inputs
  2. Buttons
  3. Checkbox
  4. Radio box
  5. File Select
  6. Form Tag

Samacheer Kalvi 12th Computer Applications Solutions Chapter 8 Forms and Files

  1. Text inputs contain textbox and text area controls.
  2. Buttons may contain Submit button, Reset button and Cancel Button.
  3. Checkbox is the important feature which selects more than one value from the HTML form.
  4. Radio box is similar to checkbox but one value can be chosen at a time.
  5. File select is the best feature to select one file from the local machine to server machine at a time.
  6. Form tag is used to mention a method (POST or GET) and control the entire form controls in the HTML document

Samacheer Kalvi 12th Computer Applications Solutions Chapter 8 Forms and Files

Question 3.
Explain the process File handling?
Answer:
File handling is an important activity of all web application development process. Files are processed for different tasks using the following events:

  1. PHP Open a File,
  2. PHP Read a File,
  3. PHP Close a File,
  4. PHP Write a File,
  5. PHP Appending a File and
  6. PHP uploading a File.

1. Open a File:
fopen( ) is a system function available in PHP. This function helps to open a file in the server. It contains two parameters one for the file and the other one specifies in which mode the file should be opened (Read/Write).
Syntax:
$file_Object= fopen(“FileName”, “Read/WriteMode”) or die(“Error Message!”);
Example:
<?php
Smyfile = fopen(“Student.txt’’, “r”) or die(“Unable to open file!”);
?>

2. Read a File:
The fread( ) function reads from an open file. The file object comes from fopen function.
Syntax:
ffead($file_Object,filesize(“FileName”));
Example:
<?php
fread($myfile,filesize(“Student.txt”));
?>

3. Close a File:
The fclose( ) function is used to close an opened file. The file object comes from fopen function.
Syntax:
fclose($file_Object);
Example:
fclose($myfile)

4. write a File:
The fwrite( ) function is used to write to a file.
Syntax:
fwrite($myfile, $txt);
Example:
fwrite($myfile, $txt)

5. Appending a File
The file_put_contents( ) function is used to Append to a file. The various parameters used in appending a file are
Syntax:
file_put_contents(file, data, mode, context)
Samacheer Kalvi 12th Computer Applications Solutions Chapter 8 Forms and Files

6. File Upload:

  1. File upload is the best feature to select one file from the local machine to server machine.
  2. Form tag is used to mention a method as POST or GET and encrypt attribute mentioned as “multipart/form-data”.
  3. In the <Input> tag mention type=”file” attribute shows the input field as a file-select control, with a “Browse” button next to the input control. The form above sends data to a file called “Student_photo_upload.php”.
  4. First, ensure that PHP is configured to allow file uploads.
  5. In Server machine “php.ini” file, search for the file_uploads directive, and set it to On:
    “file_upIoads = On”

Samacheer Kalvi 12th Computer Applications Solutions Chapter 8 Forms and Files

Question 4.
Explain concepts of HTTP Uploading process?
Answer:
File Upload:
1. File upload is the best feature to select one file from the local machine to server.machine. Form tag is used to mention a method as POST or GET and encrypt attribute mentioned as “multipart/form-data”.

2. In the <Input> tag mention type=”file” attribute shows the input field as a file-select control, with a “Browse” button next to the input control.

3. The form above sends data to a file called “Student_photo_upload.php”.

4. First, ensure that PHP is configured to allow file uploads.

5. In Server machine “php.ini” file, search for the file_uploads directive, and set it to On:
“file_upIoads = On”

6. After submitting the upload button the request reaches to Student_photo_upload.php file. In the file $_FILES variable collects all uploaded file information such as name of the file, size of the file and extension of the file etc.

7. All the details are checked thoroughly and the errors are saved in an array variable.

8. The file finally moves under the image directory if the array error variable is empty.

Samacheer Kalvi 12th Computer Applications Solutions Chapter 8 Forms and Files

Question 5.
Explain in detail of File handling functions?
Answer:
File handling is an important activity of all web application development process. Files are processed for different tasks using the following events:

  1. PHP Open a File,
  2. PHP Read a File,
  3. PHP Close a File,
  4. PHP Write a File,
  5. PHP Appending a File and
  6. PHP uploading a File.

1. Open a File
fopen( ) is a system function available in PHP. This function helps to open a file in the server. It contains two parameters one for the file and the other one specifies in which mode the file should be opened (Read/Write).
Syntax:
$file_Object= fopen(“FileName”, “Read/WriteMode”) or die(“Error Message!”);
Example:
<?php
$myfile = fopen(“Student.txf’, “r”) or die(“Unable to open file!”);
?>

2. Read a File:
The ffead( ) function reads from an open file. The file object comes from fopen function.
Syntax:
fread($file_Object,filesize(“FileName”));
Example:
<?php
fread($myfile,filesize(“Student,txt”));
?>

3. Close a File:
The fclose( ) function is used to close an opened file. The file object comes from fopen function.
Syntax:
fclose($file_Object);
Example:
fclose($myfile);

4. write a File:
The fwrite( ) function is used to write to a file.
Syntax:
fwrite($myfile, $txt);
Example:
fwrite($myfile, $txt);

5. Appending a File
The file_put_contents( ) function is used to Append to a file. The various parameters used in appending a file.
file_put_contents (file, data, mode, context)
Samacheer Kalvi 12th Computer Applications Solutions Chapter 8 Forms and Files

6. File Upload:
1. File upload is the best feature to select one file from the local machine to server machine.
Form tag is used to mention a method as POST or GET and encrypt attribute mentioned as “multipart/form-data”.

2. In the <Input> tag mention type=“file” attribute shows the input field as a file-select control, with a “Browse” button next to the input control. The form above sends data to a file called “Student_photo_upload.php”.
Note: First, ensure that PHP is configured to allow file uploads.

3. In Server machine “php.ini” file, search for the file_uploads directive, and set it to On:
“fileuploads = On”

Samacheer Kalvi 12th Computer Applications Solutions Forms and Files Additional Question and Answer

1. Choose the Best Answer

Question 1.
………………………… inputs contain text box and text area controls.
Answer:
Text

Question 2.
Pick the odd one out.
(a) Submit
(b) Reset
(c) File
(d) Cancel
Answer:
(c) File

Samacheer Kalvi 12th Computer Applications Solutions Chapter 8 Forms and Files

Question 3.
Which one of the control selects more than one value from the HTML form?
Answer:
(a) Checkbox
(b) Reset
(c) Buttons
(d) Text
Answer:
(a) Checkbox

Question 4.
…………………………. is used to select one value can be chosen at a time.
(a) Checkbox
(b) Radio box
(c) Textbox
(d) File
Answer:
(b) Radio box

Samacheer Kalvi 12th Computer Applications Solutions Chapter 8 Forms and Files

Question 5.
Which is the best feature to select one file from the local machine to server machine at a time?
(a) Radio box
(b) Check box
(c) File select
(d) Textbox
Answer:
(c) File select

Question 6.
Find the Incorrect pair.
(a) Radio box – one value a time
(b) File select – Select one file from local machine to server
(c) Text – Text Box
(d) Input – Text Area
Answer:
(d) Input – Text Area

Samacheer Kalvi 12th Computer Applications Solutions Chapter 8 Forms and Files

Question 7.
Which tag is used to mention POST or GET method?
(a) Frame
(b) Form
(c) File
(d) Input
Answer:
(b) Form

Question 8.
…………………………. is an attribute of form tag in HTML.
(a) post
(b) Get
(c) method
(d) php get
Answer:
(c) method

Samacheer Kalvi 12th Computer Applications Solutions Chapter 8 Forms and Files

Question 9.
In get method, the input data sent URL address is known as …………………………….
Answer:
query string

Question 10.
………………………. is a process of checking the input data submitted by the user from client machine.
(a) collection
(b) verification
(c) validation
(d) Report
Answer:
(c) validation

Question 11.
How many types of validation are available in PHP?
(a) 1
(b) 2
(c) 3
(d) 4
Answer:
(b) 2

Samacheer Kalvi 12th Computer Applications Solutions Chapter 8 Forms and Files

Question 12.
The two types of validation are ………………………. and …………………………. validation.
Answer:
client side and server-slide

Question 13.
Pick the odd one out
(a) PHP
(b) JS
(c) JSP
(d) ASP
Answer:
(b) JS

Question 14.
Find the statement which is true.
(a) The input data validations are performed on the clients machine’s web browser
(b) The input data validations are performed on the server machine
Answer:
(a) The input data validations are performed on the clients machine’s web browser

Samacheer Kalvi 12th Computer Applications Solutions Chapter 8 Forms and Files

Question 15.
The “required” attributed in HTML input tags are present in ………………………. validation.
(a) server side
(b) client side
(c) PHP script
(d) script code
Answer:
(b) client side

Question 16.
Which one of the following is not an back-end application?
(a) CGI
(b) HTML
(c) ASP Script
(d) PHP Script
Answer:
(b) HTML

Samacheer Kalvi 12th Computer Applications Solutions Chapter 8 Forms and Files

Question 17.
How many parameters are there in fopen( ) functions?
(a) 1
(b) 2
(c) 3
(d) 4
Answer:
(b) 2

Question 18.
The …………………………… function reads from an open file.
Answer:
fread( )

Question 19.
Which function is used to append to a file?
(a) fread( )
(b) fopen( )
(c) file_put_contents( )
(d) fwrite( )
Answer:
(c) file_put_contents( )

Samacheer Kalvi 12th Computer Applications Solutions Chapter 8 Forms and Files

Question 20.
How many parameters are there in file_put_contents( ) function?
(a) 2
(b) 3
(c) 4
(d) 5
Answer:
(c) 4

Question 21.
How many parameters are required and options in the file_put_contents( )?
(a) 1,2
(b) 2,2
(c) 3,2
(d) 2,1
Answer:
(b) 2,2

Samacheer Kalvi 12th Computer Applications Solutions Chapter 8 Forms and Files

Question 22.
The data to be written to the file cannot be …………………………….
(a) string
(b) pointers
(c) array
(d) data stream
Answer:
(b) pointers

Question 23.
………………….. is set of options in append that can modify the behaviour of a stream.
(a) file
(b) data
(c) mode
(d) context
Answer:
(d) context

Samacheer Kalvi 12th Computer Applications Solutions Chapter 8 Forms and Files

Question 24.
In the file $_FILES variable collect all uploaded file information such as
(a) name of the file
(b) size of the file
(c) extension of the file
(d) all the above
Answer:
(d) all the above

Question 25.
The file finally moves under the ……………………… directory if the array error variable is empty.
(a) image
(b) post
(c) get
(d) file
Answer:
(a) image

Question 26.
AJAX me ……………………………………..
Answer:
Asynchronous Javascript

Samacheer Kalvi 12th Computer Applications Solutions Chapter 8 Forms and Files

Question 27.
AJAX uses ………………………… to display the data.
Answer:
HTML DOM

II. Short Answer

Question 1.
Give the syntax for fopen( ) function?
Answer:
Syntax:
$file_Object= fopen(“FileName”, “ReadAVriteMode”) or die(“Error Message!”);

Samacheer Kalvi 12th Computer Applications Solutions Chapter 8 Forms and Files

Question 2.
Give the syntax for fread( ) function?
Answer:
Syntax:
fread($file_Object,filesize(“FileName”));

III. Explain in Brief Answer

Question 1.
Write note on client-side validation?
Answer:
Client-Side Validation: The input data validations are performed on the client machine’s web browsers using client side scripts like Java script or adding “required” attribute in HTML input tags.

Samacheer Kalvi 12th Computer Applications Solutions Chapter 8 Forms and Files

Question 2.
What is meant by Server side validation?
Answer:
Server Side Validation: After the submission of data, validations are performed on the server side using the programming like PHP, ASP or JSP etc. available in the server machine.

Question 3.
Write a code to do validation in client side?
Answer:
Example:
<input> required Attribute in HTML <form action=“welcome.php”>
Username: <input type=“text” name=“name” required>
<input type=“submit”>
</form>
Samacheer Kalvi 12th Computer Applications Solutions Chapter 8 Forms and Files

Samacheer Kalvi 12th Computer Applications Solutions Chapter 8 Forms and Files

Question 4.
Give the syntax for fclose( ) function?
Answer:
Syntax:
fclose($file_Objecdt):

Question 5.
Explain various parameters used in appending the file?
Answer:
Samacheer Kalvi 12th Computer Applications Solutions Chapter 8 Forms and Files

IV. Explain in detail

Question 1.
Write a HTML program to produce the following output?
Samacheer Kalvi 12th Computer Applications Solutions Chapter 8 Forms and Files
Test.html:
<html>
<body>
<form action=“welcome.php” method=“post”>
Name: <input type=“text” name=“name”><br>
E-mail: <input type=“text” name=“email”><br>
<input type=“siibmit”>
</form>
</body>
– </html>
Welcome.php:
<html>
<body>
Welcome <?php echo $_POST[“name”]; ?><br>
Your email address is: <?php echo $_POST[“email”]; ?> </body>
</html>

Samacheer Kalvi 12th Computer Applications Solutions Chapter 8 Forms and Files

Question 2.
Explain how to append a file in PHP?
PHP Appending a File
Answer:
The file_put_contents( ) function is used to Append to a file.
Syntax:
file_put_contents(file, data, mode, context)
Samacheer Kalvi 12th Computer Applications Solutions Chapter 8 Forms and Files
Example:
<?php
$txt = “Student id”;
Smyfile = file_put_contents(Togs.txt’, $txt.
PHP EOL, FILEAPPEND | LOCK_EX);
?>

Leave a Comment

Your email address will not be published. Required fields are marked *