Page 1
Sample Paper
&
Question Paper Pattern
2022
2023
GOA BOARD
Page 2
Std. XII Web Technology
Distributions of Marks are as follows:
Unit I Database Concept 10 Marks
Unit II MYSQL Basics 10 Marks
Unit III MYSQL Advanced & PHP Basic 10 Marks
Unit IV PHP Advanced 10 Marks
Unit V Advancing MYSQL through PHP 10 Marks
Total : 50 Marks
Unit I • Introduction to database (10 Marks)
File, record, Entity, attributes
Types of users 1. Naïve users 2. Online users 3. Application Programmer
4. Database administrator
3-Level Architectural proposal 1. Internal Level 2. Conceptual level 3. External Level
Characteristics of DBMS, Advantages & disadvantages of DBMS
Data Independence(Logical & Physical) Schema Data Abstraction Data redundancy
Data Integrity
• Database security (pg no:235) • Privacy of data.
Preserving policies of the organization,
System related security level,
Database Integrity Access control Relational Model
Definition of Relation Key concept: super key (with eg), primary key candidate key,
composite key, secondary key, foreign key. Integrity Rule
• Integrity rule 1 - Entity Integrity • Integrity rule 2-referential integrity, domain-
Integrity.
NULL Value Concept. Database Design Schema Subschema:
Entity-Relationship Data Model (E-R Model) 1. Library 2. Pay
roll 3. Banking 4. Admission of students 5. Hospital Management
Page 3
Unit - II (To Acquire basic knowledge of working with Mysql) (10 mks)
MYSQL BASICS (Ref. book The complete reference Mysql By Vikram Vaswant McGraw
Hill Publication) • Introduction to Mysql
• Installation:
• The MySQL commands: select , insert, update, delete, index, alter, create, drop, Exit,
quit, shutdown, file, copy, limit
• Data Types : Text, Numbers, Date and time
• Numeric types: Tinyint, Mediumint, Integer, Smallint, Bigint, Float,double
• String types: Char, varchar, tinytext, mediumtext, longtext
• Arithmetic operators . Comparision operators , Logical operators
• Query commands : WILD CARDS, SELECT, WHERE.DISTINCT.GROUP BY,
HAVING, UPDATE IN LIKE, ORDER BY ,
BETWEEN.SELECT DATA.INNER JOIN, OUTER JOIN,
UNION
Unit III - (5+5mks) (To Acquire Advance knowledge of working with Mysql & PHP)
MYSQL Advanced & PHP Basic (10 mks)
Functions
Math functions: Abs(), ceiling, floor(), greatest, least(), rand(), round(), sign(), sqrt(),
truncate().
Aggregate function : Avg(), count(), min(), max(), sum()
String functions: ASCII), concat(), chát().insert(), lower(), left() length(), ltrim() repeat(),
reverse(), Right(), rtrim(), stremp(), substring(), trim(), upper()
Date and time function: Curdate(), curtime(), date_add(), date_format(), date_sub(),
dayofweek(), Dayofmonth(), dateofyear(), dayname(), month(), monthname(), now(),
period_ add(), Period_diff(), hour(), minute(), second() to_days(). Trigger & Views(Only
theory concept) Ref. Mysql by Larry Ullman
Views : Diff between view and a table.
INTRODUCTION to PHP
Beginning and ending block of PHP statement
Tag style , Standard tags ,Script tags,
Print, Use of echo, Adding comments to php code, VARIABLES Dynamic variables,
Data types Integer, whole number, double, string, Boolean, array
Arithmetic operator, Comparisons operator, The concatenation operator, operator
assignment, Precedence of operator,
The if statement if else clause, switch statement
Page 4
For loop, While, Do while loop, for ..each
Function, Global variables
Creating an array, Defining arrays with array() ,Associative arrays, Looping
through an array
Unit IV (10 mks)
Advanced php (Ref W3school php)
Including files with file include(/require ,
The $ GET Variable, The $ POST Variable
File upload , Types of Error
PHP Session Variables
Opening a File, fopen(), fclose()
The File may be opened in one of the following modes:
Modes Description
R Read only. Starts at the beginning of the file. r+
Read/Write. Starts at the beginning of the file.
W Write only. Opens and clears the contents of file or creates a new file if it doesn't
exist.
W Read/Write.Opens and clears the contents of file; or creates a new file if it
doesn't exist.
A Append. Opens and writes to the end of the file or creates a new file if it doesn't
exist.
a+ Read/Append. Preserves file content by writing to the end of the file.
X Write only. Creates a new file. Returns FALSE and an error if file already
exists.
Unite V
MYSQL PHP Connectivity
1. mysql_connect()
2. mysql_create_db()
3. mysql_drop_db()
4. mysql_fetch_array()
5. mysql_close()
6. mysql_num_row()
7. mysql_query()
8. mysql_select_db()
9. mysql-select()
10. mysql_error()
Page 5
Unit Unit Name Quarterly Test Weightage for Weightage for Internal
No. 1 ,2 and 3 First Second Term Scheme
Term Examination
(Marks) Examination (Marks)
(Marks)
1 Database 6
Concept
2 MYSQL 7
Basics 20 + 20
3 MYSQL 7
Advanced &
PHP Basic
4 PHP 10
Advanced
20
5 Advancing 10
MYSQL
through PHP
Connectivity
3 Qtly tests to be 10 20 20
converted to 10
marks =60/6=10
(Theory)
Distribution of portion for Mid Term, First Term and Second Term Examination.
Before 1 Term two Quarterly test conducted 20 marks each from Unit 1 and Unit
II and III(Advance MYSQL).
Page 6
After 1 Term Examination third Quarterly test conducted for 20 marks from Unit
III (PHP) IV and V
List of Practical
1. Using MYSQL Basic Command to frame query
2. To set relationship and access data from Multiple tables
3. Installation of WAMP server
4. To Create forms Using Validation
5. To manipulate String
6. Select the Command using specific field or all.
7. Select using wildcard and condition
8. Form Query Using Update, Delete Order by, Alter ,Having, Group by, Joins, date
function, Drop,
(All Programs to be written in HTML Code )
9. Programs on Loops(for, While ,do while, )
10.Programs on Decision Statement (if, if else, nested if, Switch )
11.Programs on Array
12.Programs on String
13.Design a login form to add a record using OK and cancel Button.
14.Design a form for Update and delete a Record.
15.Program to retrieve a record in a table form.
16.Menu Driven Programs for Add ,Update, Delete and View a data
17.Program to input data and display the report and Print.
Page 7
LIST OF PRACTICALS TO BE COVERED FOR MYSQL FOR THE YEAR 2022-2023.
(Additional practicals as required may be done by the respective teacher.)
1. Create database Employee.
Table : Emp_tbl.
Fields : Employee_id, Name, Address, Salary, Age.
Construct MySQL queries with reference to the above structure.
a. Enter a data record in Emp_tbl.
b. List all the records from eEmp_tbl.
c. Add a coloum date of birth between address and salary.
d. Display Employee_id and Names of employees whose age is less than 30.
2. The Salary table has fields EmployeeId, Name, BasicSalary.
Construct Mysql queries:
a. To add a record to the table.
b. To view all the records from the table.
c. To display the highest BasicSalary from table.
d. To remove column Name from table.
3. The Invoice table has the fields InvoiceNumber, Description, Quantity, Amount.
Construct Mysql Queries :
a. To display the structure of the table.
b. To remove all the records whose amount is below 5000.
c. To insert invoice_date between InvoiceNumber and description.
d. To display the total amount of all the records from the table.
Page 8
4. The BANKS table has the fields CustomerID, Name, Age, Amount
Construct MYSQL queries for the following:
a. Add a record.
b. Delete records of customer whose age is less than 40.
c. Change the name of the Field amount to deposit.
d. Insert a field address between name and age.
5. The PAY table has the fields EmployeeID, Name, date_of_birth, salary
Construct MYSQL queries for the following:
a. Create pay table.
b. Display total salary of employees.
c. Display EmployeeID, name and salary in descending order of name.
d. Change the name of table Pay to Pay_tbl.
6. Table: Student
Fields: Roll no, Name, DOB.
Construct MYSQL queries for the following:
a. Display name, date of birth and day on which student is born.
b. Display name and age of each student.
c. Display names of all students who are born in December.
d. To change date of birth of a student as 01 Jan 2000 whose name is “ANMOL”.
7. Table: Payroll
Fields: Emp_id, name, state, salary.
Construct MYSQL queries for the following:
a. Insert another field ‘DESIGNATION’ in the table with length 10 and of character data type
after field name.
b. To arrange records is descending order based on their salary.
c. Display all the employees whose designation is programmer and salary is more than 50,000.
d. To display total number of employee from each state.
8. With reference to the given structure of the table, construct the following queries:
The database ‘Employee’ contains table ‘E_tbl’ table with fields Emp_id, Emp_Name, Dob, State,
Salary.
Page 9
a. Display Emp_id, Emp_name and Salary in the descending order of the Emp_name.
b. Display state and the total number of employees from each state.
c. Insert another field ‘ Gender’ in the table with length 6 and of char data type, after the field
Emp_name.
d. Change the value of the field ‘Dob’ to 2012-10-12 whose salary is greater than 25000.
9. Construct MySQL queries for the following: Table : Inventory.
Fields : itemid, itemname, price, qty.
a. To arrange the records as per price in descending order.
b. Display itemid, itemname of all the items where quantity is between 5 to 10.
c. To remove the records where itemname is “Transistor”.
d. Display name of all items whose price is greater than 10000.
10. Create a Database: Customer.
Table 1: Cust_tbl.
Fields: Customerid, Name, Address.
Table 2: Bill_tbl.
Fields: Customerid, Productid, Quantity, Amount.
Construct MYSQL queries for the following:
a. To list Customerid, Productid, Amount from Bill_tbl whose Amount exceeds 1,000.
b. To enter a data record in Cust_tbl.
c. To display all the records from multiple tables by combining Cust_tbl and Bill_tbl.
d. To remove Address column from Cust_tbl.
Students need to perform at least 5 Practical from the above list
Write PHP programs to
1. Generate first n numbers.
2. Check if a given number is even or odd.
3. Generate first n even /odd numbers.
4. Generate n numbers starting from 5.
5. Generate n even numbers starting from 10.
6. Generate n odd numbers starting from 7.
7. Generate even / odd numbers less than a given number.
8. Generate even / odd numbers between given 2 numbers.
9. Find the sum of the first n numbers.
Page 10
10. Find the sum of the squares of the first n numbers.
11. Find whether a given number is positive, negative or zero.
12. Find area of a triangle using the formula: area = √s(s−a)(s−b)(s−c) where s = (a+b+c) / 2.
13. Find the roots of a quadratic equation.
14. Find the average of the first n numbers.
15. Find the sum of digits of a number.
16. Reverse a given number.
17. Find the factorial of n.
18. Find Permutation.
19. Find Combination.
20. Generate Fibonacci series i.e. 0 1 1 2 3 5 8 13 21 …
21. Generate multiplication table.
22. To check if a given number is Armstrong or not.
23. Reverse a given string.
24. To check if a given number is prime or not.
25. To check if a given string is palindrome.
26. To count the number of vowels in a given string.
27. To count the number of words in a given string.
28. To count the number of occurrences of each vowel in a given string.
29. Count the number of elements in an array.
30. Find the maximum value in an array.
31. Find the least value in an array.
32. Sort values from the array.
33. Given values in an array A, put all even numbers in array E and odd numbers in array
34. Design a login form to add a record using OK and cancel Button.
35. Design a form for Update and delete a Record.
36. Program to retrieve a record in a table form.
37. Menu Driven Programs for Add ,Update, Delete and View a data
38. Program to input data and display the report and Print.
Teachers need to do any two practical between sr no 1 to 5, any two practical between srno 6
to 10 and so on. serial no 34 to 38 all 5 Over all at least 15 practical’s need to be performed
from the list mentioned above by the students.
Page 12
GOA BOARD OF SECONDARY & HIGHER SECONDARY EDUCATION
ALTO – BETIM, GOA
PROFORMA FOR ANALYSIS OF QUESTION PAPER
1 Term
Subject: Web Technology Year of Examination: 2022-23
Class: XII Computer Technique Max. Marks: 20 Time alloted: 1 hr
1. Sections if any: - NIL
2. Total No. of questions and marks: -
No. of questions No. of questions Total marks for all the Maximum marks for
set in the paper to be attempted questions set in the paper attempted questions
20 20 20 20
3. Study of options:
(a) Overall options in the whole question paper:- -NO-
(b) Overall options within the sections: - -NO-
(c) Overall options within a question: - -NO-
(d) Internal option within the question: - -NO-
(e) Comparability options: -
4. Instructions for examiners: - AS PER PATTERN
5. Directions in individual question: - -NIL-
6. Allocation of marks question-wise and part-wise: Q1 to Q20 - each with 1 mark
7. General format
(a) Arrangement of question, numbering and printing etc.:
Q1 to Q20
Page 13
8. Question - wise analysis
Sr. no. Objective Content Form of Definiteness Difficulty Marks Time
Language of
Questions
Part Area the of the level of the alloted in
no Major area questions answers questions min.
of content
topic
Q1 K D.C VSA Definite Easy 1 3
Q2 K D.C VSA Definite Easy 1 3
Q3 K D.C VSA Definite Easy 1 3
Q4 K D.C VSA Definite Average 1 3
Q5 K D.C VSA Definite Average 1 3
Q6 K D.C VSA Definite Average 1 3
Q7 K MYSQL. B VSA Definite Easy 1 3
Q8 K MYSQL. B VSA Definite Easy 1 3
ENGLISH
Q9 K MYSQL. B VSA Definite Average 1 3
Q10 K MYSQL. B VSA Definite Average 1 3
Q11 K MYSQL. B VSA Definite Average 1 3
Q12 K MYSQL. B VSA Definite Difficult 1 3
Q13 K MYSQL. B VSA Definite Difficult 1 3
Q14 K MYSQL. A VSA Definite Easy 1 3
Q15 K MYSQL. A VSA Definite Easy 1 3
Q16 K MYSQL. A VSA Definite Easy 1 3
Q17 K MYSQL. A VSA Definite Average 1 3
Q18 K MYSQL. A VSA Definite Average 1 3
Q19 U MYSQL. A VSA Definite Difficult 1 3
Q20 K MYSQL. A VSA Definite Difficult 1 3
A. Weightage to Objectives:
Weightage
Sr. No. Objectives
Marks Percentage
1 Knowledge 8 40%
2 Understanding 8 40%
3 Application 8 20%
4 Skill
B. Weightage to Content/Subject Units
Sr. No. Units No. of Questions Marks Percentage
1 Database Concepts 6 6 30%
2 MYSQL Basic 7 7 35%
3 MYSQL Advance & PHP 7 7 35%
Basic
C. Coverage of topics
Page 14
No. of topics in the syllabus Topics covered Percentage
03 03 100%
D. Weightage to form of questions
Sr. No. Form of questions Marks for No. of Total Percentage
each questions Marks
question
1 Very Short Answer Type (VSA) 1 20 20 100%
2 Short Answer Type (SA-I) - - - -
3 Short Answer Type (SA-II)
- - - -
4 Long Answer Type(LA)
- - - -
Total 20 20 100%
E. Language of Questions :
Definiteness No. of questions Marks Percentage
Definite 20 20 100%
Partly Definite - - -
Not Definite - - -
F. Difficulty Level
Levels of difficulty No. of Questions Marks Percentage
Easy 8 8 40%
Average 8 8 40%
Difficult 4 4 20%
Page 15
Goa Board of Secondary & Higher Secondary Education, Alto, Betim – Goa
BLUE PRINT OF HSSCE EXAMINATION ( FIRST TERM )
Duration: - 1 hour Subject: Web Technology
Maximum marks: - 20
Knowledge Understanding Application Skill
Objective Total
s→
Content
Area SA- SA- SA- SA L
VSA SA-I LA VSA SA-I LA VSA SA-I LA VSA SA-I
II II II -II A
Database
Concept
3(1) - - - 3(1) - - - - - - - - - - 6(6)
Note:
MySql
Basic
3(1) 3(1) 1(1) 7(7)
MYSQL
Advanced
2(1) 2(1) 3(1) 7(7)
& PHP
Basic
Total 8(1) 8(1) 4(1) - 20(20)
Figures outside the brackets indicate the number of questions and figures within brackets indicate marks.
For example, 4(2).
*Indicates option
Page 16
Time :-1 Hour First Term Web Technology
Total No of Question :20 Subject Code:-V4317 Max Marks:- 20
Instruction: - All Multiple- Choice Question are Compulsory.
Each question carries 1 Marks.
Write the number of each question clearly on the answer-book.
Select the correct alternative from given choices.
1 Related fields in a database are grouped to form a
A. Data item
B. DBMS
C. Record
D. Attribute
2 In DBMS architecture , the external level is the
A. physical level.
B. logical level.
C. conceptual level
D. view level.
3 The DBMS architecture ,ability to modify the conceptual schema without causing
any changes in the schema followed at external level is
A. Data Manipulation
B. Logical Data Independence
C. Physical Data Independence
D. Data Redundancy
4 A Key to represent the relationship between tables is
A. Primary key
B. Secondary Key
C. Foreign Key
D. None of the above
5 In an E-R diagram an entity set is represented by a
A. rectangle.
B. ellipse.
C. diamond box.
D. circle.
6 The rule which specifies that a value which appears in one relation for a given set
of attributes also appears for a certain set of attributes in another relation is
A. Entity Integrity rule
B. Referential Integrity rule
C. Data Integrity rule
D. Domain Integrity rule.
7 What is the output of query SELECT DAYOFMONTH(‘2014-03-01’);
Page 17
A. 14
B. 03
C. 01
D. 20
8 What is the maximum length of Char Column ?
A. 256
B. 255
C. 1024
D. None
9 Identify the table name in the following SQL statement. INSERT INTO student
VALUES ('John','Mumbai');
A. John
B. Mumbai
C. Values
D. Student
10 Which statement is used to select a default database?
A. Drop
B. Create
C. Use
D. Database
11 With SQL, how do you select a column named "FirstName" from a table named
"Persons"?
A. EXTRACT FirstName FROM Persons
B. SELECT Persons.FirstName
C. SELECT FirstName FROM Persons
D. SELECT Persons. FROM Persons
12 With SQL, how can you return the number of records in the "Persons" table?
A. SELECT COUNT(*) FROM Persons
B. SELECT LEN(*) FROM Persons
C. SELECT COLUMNS(*) FROM Persons
D. SELECT NO(*) FROM Persons
13 With SQL, how can you return all the records from a table named "Persons" sorted
descending by "FirstName"?
A. SELECT * FROM Persons ORDER BY FirstName DESC
B. SELECT * FROM Persons SORT 'FirstName' DESC
C. SELECT * FROM Persons SORT BY 'FirstName' DESC
D. SELECT * FROM Persons ORDER FirstName DESC
14 Which is the function adds two or more expressions together.
Page 18
A. CONCAT()
B. ADD()
C. INSERT()
D. LOWER()
15 What is the output of the Query SELECT SQRT(64)
A. 10
B. 4
C. 6
D. 8
16 Identify the output of the query
SELECT LCASE("SQL Tutorial is FUN");
A. sql tutorial is fun
B. SQL TUTORIAL IS FUN
C. Sql Tutorial is fun
D. Bothe A and B
17 Which Command Is Used To Remove All Rows From A Table?
A. Delete
B. Truncate
C. Remove
D. Both A & B
18 Identify the function that returns 0 if the strings are the same, -1 if the first argument
is smaller than the second according to the current sort order, and 1 otherwise.
A. Strcmp()
B. Copy()
C. Substr()
D. Srtcmp()
19 The Function reverses a string and returns the result
A. RESVER()
B. OPP()
C. APPEND()
D. RESERVE()
20 What is the output of the Query
SELECT LENGTH("SQL Tutorial") AS LengthOfString;
A. 12
B. 15
C. 10
D. 8
Page 19
Answer Key
1 C
2 D
3 B
4 C
5 A
6 B
7 C
9 D
10 C
11 C
12 A
13 A
14 A
15 D
16 A
17 A
18 A
19 D
20 A
Page 20
GOA BOARD OF SECONDARY & HIGHER SECONDARY EDUCATION
ALTO – BETIM, GOA
PROFORMA FOR ANALYSIS OF QUESTION PAPER
II Term
Subject: Web Technology Year of Examination: 2022-23
Class: XII Computer Technique Max. Marks: 20 Time alloted: 1 hr
1. Sections if any: - NIL
2. Total No. of questions and marks: -
No. of questions No. of questions Total marks for all the Maximum marks for
set in the paper to be attempted questions set in the paper attempted questions
09 09 20 20
3. Study of options:
(a) Overall options in the whole question paper:- -NO-
(b) Overall options within the sections: - -NO-
(c) Overall options within a question: - -NO-
(d) Internal option within the question: - -NO-
(e) Comparability options: -
4. Instructions for examiners: - AS PER PATTERN
5. Directions in individual question: - -NIL-
6. Allocation of marks question-wise and part-wise: Section A Q1 to Q2 1 marks Each
Section B Q3 to Q7 2 Marks Each
Section C Q8 To Q9 4 Marks Each
7. General format
(a) Arrangement of question, numbering and printing etc.:
Q1 to Q9
Page 21
8. Question - wise analysis
Sr. Objective Content Form of Definiteness Difficulty Marks Time
Language of
Questions
no. Area the of the level of the alloted in
Part Major area questions answers questions min.
no of content
topic
Q1 Php Advance SA1 Definite Easy 1 3
Q2 Php Advance SA1 Definite Easy 1 3
Q3 Php Advance SA2 Definite Average 2 6
Q4 Php Advance SA2 Definite Average 2 6
ENGLISH
Q5 Php Advance SA2 Definite Average 2 6
Q6 Php Advance SA2 Definite Average 2 6
Q7 Php Advance SA2 Definite Average 2 6
Q8 Advancing LA Not Definite Difficult 4 12
Q9 MYSQL LA Not Definite Difficult 4 12
through PHP
A. Weightage to Objectives:
Weightage
Sr. No. Objectives
Marks Percentage
1 Knowledge 2 10%
2 Understanding 8 40%
3 Application 10 50%
4 Skill
B. Weightage to Content/Subject Units
Sr. No. Units No. of Questions Marks Percentage
1 Php Advance 6 10 50%
2 Advancing MYSQL 3 10 50%
through PHP
C. Coverage of topics
No. of topics in the syllabus Topics covered Percentage
02 02 100%
Page 22
D. Weightage to form of questions
Sr. No. Form of questions Marks for No. of Total Percentage
each questions Marks
question
1 Short Answer Type (SA-I) 1 2 2 10%
2 Short Answer Type (SA-II) 2 5 10 50%
3 Long Answer Type(LA)
4 2 8 40%
4
- - - -
Total 20 20 100%
E. Language of Questions :
Definiteness No. of questions Marks Percentage
Definite 7 12 60%
Partly Definite - - -
Not Definite 2 8 40%
F. Difficulty Level
Levels of difficulty No. of Questions Marks Percentage
Easy 2 2 10%
Average 5 10 50%
Difficult 2 8 40%
Page 23
Goa Board of Secondary & Higher Secondary Education, Alto, Betim – Goa
BLUE PRINT OF HSSCE EXAMINATION ( FIRST TERM )
Duration: - 1 hour Subject: Web Technology
Maximum marks: - 20
Objectives Knowledge Understanding Application Skill
Total
→
Content VS SA- L
SA-I SA-II LA VSA SA-I SA-II LA VSA SA-I SA-II LA VSA SA-I
Area A II A
PHP
- 2(1) - - - 4(2) - - - - - - - - - 6(10)
Advanced
Advancin
g MYSQL
through
PHP - - 1(2) 2(4) 3(10)
Connectivit
y
Total 2(1) 4() 3(10) - 9(20)
Note: Figures outside the brackets indicate the number of questions and figures within brackets indicate marks.
For example, 4(2).
*Indicates option
Page 24
Time :-1 Hour Second Term Web Technology
Total No of Question :20 Subject Code:-V4317 Max Marks:- 20
Instruction: - All question are Compulsory
There are three section in this question Paper (A,B,C)
In Section A there are 2 question to be answer in 1 and 2 Sentence.
In Section B there are 5 question to be answer in 2 and 3Sentence.
Write PHP code in Section C.
Write the number of each question clearly on the answer-book.
1 What is the full form of PHP ? 1
2 Which symbol is used to declare a PHP variable. 1
3 Explain $POST with an Example. 2
4 Explain while loop with an example. 2
5 Briefly Explain File Upload in PHP. 2
6 State 2 points of difference between View and Table 2
7 Explain Mysql_connect( ) with an example. 2
8 Write a PHP code to delete a record using student_id 4
Database : student
Table : std_table
Fields : student_id, name, address, gender
9 Write PHP code to insert data in the following form, store in the database. 4
Database :myDB
Table : MyGuests
Fields:-firstname,lastname,email.
Page 25
Answer Key
1 Hypertext Preprocessor
2 var
3 The predefined $_POST variable is used to collect values from a form sent with
method="post".
Information sent from a form with the POST method is invisible to others and has
no limits on the amount of information to send.
Note: However, there is an 8 Mb max size for the POST method, by default (can
be changed by setting the post_max_size in the php.ini file).
Example
<form action="welcome.php" method="post">
Name: <input type="text" name="fname" />
Age: <input type="text" name="age" />
<input type="submit" />
</form>
When the user clicks the "Submit" button, the URL will look like this:
http://www.w3schools.com/welcome.php
The "welcome.php" file can now use the $_POST variable to collect form data
(the names of the form fields will automatically be the keys in the $_POST array):
Welcome <?php echo $_POST["fname"]; ?>!<br />
You are <?php echo $_POST["age"]; ?> years old.
When to use method="post"?
Information sent from a form with the POST method is invisible to others and has
no limits on the amount of information to send.
However, because the variables are not displayed in the URL, it is not possible to
bookmark the page.
4 While loop: If the test expression is true then the code in the statement block will
be executed. After the code has executed the test expression will again be
evaluated and the loop will continue until the test expression is found to be false.
The statement block must feature code that will affect the test expression in order
to change the evaluation result to false at some point otherwise an infinite loop
will be created.
It is important to note that if the test expression is not true when it is first
evaluated the code in the statement block is never executed.
eg to find sum of 1 to 10 numbers.
Page 26
<?php
$i=1; $sum=0;
While ($i<=10)
{$sum+=$i;
$i++;
}
echo("the sum is $sum");
?>
5
This is a very simple, yet fully functional PHP script/function to
upload files to your website. Usage and integration is simple, file
uploads can be as simple as adding one line to your PHP form
processing scripts. All you do is call a function. UPDATED: Now
supports uploading multiple files.
After uploading a file to the web server, this function will move the
file referenced by "$reference" From the PHP temporary file name &
path to the "$target" path With the file name of
basename($_FILES[reference][name]) or $fileName is it is provided.
Note: With multiple files upload, the $fileName parameter is ignored,
the files names will be the same as the original.
6 Table contains actual data and consumes physical storage.
View contains no data and does not require physical storage other
than to store the view definition (the query) because it is actually
referring to data from table
Data from a view can be selected, manipulated.
If a table that was used to create a view is dropped the view becomes
inaccessible and an error is displayed.
7 Mysql_connect() : used to connect to mysql server.It takes three
arguments which are IP address of a MYSQL server to connect , the
user name, and the password for that username.
<?php
$link = mysql_connect('localhost', 'mysql_user
', 'mysql_password');
if (!$link) {
die('Could not connect: ' . mysql_error())
;
}
echo 'Connected successfully';
mysql_close($link);
?>
Page 27
8 <?php
$servername = "localhost";
$username = "username";
$password = "password";
$dbname = "student";
// Create connection
$conn = new mysqli($servername, $username, $password,
$dbname);
// Check connection
if ($conn->connect_error) {
die("Connection failed: " . $conn->connect_error);
}
// sql to delete a record
$sql = "DELETE FROM std_table WHERE student_id =3";
if ($conn->query($sql) === TRUE) {
echo "Record deleted successfully";
} else {
echo "Error deleting record: " . $conn->error;
}
$conn->close();
?>
9
<?php
$servername = "localhost";
$username = "username";
$password = "password";
$dbname = "myDB";
// Create connection
$conn = new mysqli($servername, $username, $password,
$dbname);
// Check connection
if ($conn->connect_error) {
die("Connection failed: " . $conn->connect_error);
}
$sql = "INSERT INTO MyGuests (firstname, lastname, email)
VALUES ('John', 'Doe', '
[email protected]')";
if ($conn->query($sql) === TRUE) {
echo "New record created successfully";
} else {
echo "Error: " . $sql . "<br>" . $conn->error;
}
Page 28
$conn->close();
?>