0% found this document useful (0 votes)
8 views3 pages

PHP Sessional Exam Solutions

The document provides solutions for a PHP session exam, covering topics such as cookie attributes, MySQL features, class creation in PHP, and the differences between GET and POST methods. It also includes examples of multilevel inheritance, an employee form that processes data on the same page, session management in PHP, and updating a MySQL record. The solutions are presented in PHP code snippets and explanations.

Uploaded by

Huzeefa Pathan
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
8 views3 pages

PHP Sessional Exam Solutions

The document provides solutions for a PHP session exam, covering topics such as cookie attributes, MySQL features, class creation in PHP, and the differences between GET and POST methods. It also includes examples of multilevel inheritance, an employee form that processes data on the same page, session management in PHP, and updating a MySQL record. The solutions are presented in PHP code snippets and explanations.

Uploaded by

Huzeefa Pathan
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 3

PHP Sessional Exam - II Solutions

Q.1 Attempt any FOUR of the following:

(a) Attributes of Cookies:

1. name

2. value

3. expire

4. path

5. domain

6. secure

7. httponly

(b) Features of MySQL:

1. Open Source

2. High Performance

(c) Creating Class in PHP:

<?php

class Student {

public $name;

function setName($n) {

$this->name = $n;

function getName() {

return $this->name;

?>

(d) GET and POST Methods:

- GET: Sends data via URL, less secure, limited data.

- POST: Sends data in request body, secure, large data.


PHP Sessional Exam - II Solutions

(e) View structure of a table:

DESCRIBE table_name;

or

SHOW COLUMNS FROM table_name;

Q.2 Attempt any THREE of the following:

(a) Multilevel Inheritance:

<?php

class A {

function showA() {

echo "This is class A";

class B extends A {

function showB() {

echo "This is class B";

class C extends B {

function showC() {

echo "This is class C";

$obj = new C();

$obj->showA(); $obj->showB(); $obj->showC();

?>

(b) Employee Form (Same Page):

<?php
PHP Sessional Exam - II Solutions

$name = $designation = $salary = "";

if ($_SERVER["REQUEST_METHOD"] == "POST") {

$name = $_POST['empname'];

$designation = $_POST['designation'];

$salary = $_POST['salary'];

?>

<form method="post">

Name: <input type="text" name="empname">

Designation: <input type="text" name="designation">

Salary: <input type="number" name="salary">

<input type="submit">

</form>

<?php

echo "Name: $name, Designation: $designation, Salary: $salary";

?>

(c) Session in PHP:

<?php

session_start();

$_SESSION['username'] = "John";

echo "Session started with username.";

?>

(d) PHP to Update MySQL Record:

<?php

$conn = new mysqli("localhost", "root", "", "test");

$sql = "UPDATE employees SET salary=60000 WHERE id=1";

$conn->query($sql);

$conn->close();

?>

You might also like