Posts

Practical - 11 IWD

  AIM : Salary Slip Generation in PDF Format Using TCPDF Library salary_slip.php require_once ( 'tcpdf/tcpdf.php' ); include "db.php" ; $emp_id = 1 ; $q = mysqli_query ( $conn , "SELECT * FROM employees WHERE emp_id= $emp_id "); $row = mysqli_fetch_assoc ( $q ); $pdf = new TCPDF (); $pdf -> AddPage (); $html = " <h2 align='center'>Salary Slip</h2> <hr> Employee Name: {$row['name']} <br> Department: {$row['department']} <br> Salary: {$row['salary']} <br> "; $pdf -> writeHTML ( $html ); $pdf -> Output ( 'salary_slip.pdf' , 'I' );

Practical - 10 IWD

  Aim : Employee Management System using PHP & MySQL Database Creation CREATE DATABASE employee_db; USE employee_db; CREATE TABLE employees ( emp_id INT AUTO_INCREMENT PRIMARY KEY , name VARCHAR ( 100 ), email VARCHAR ( 100 ), password VARCHAR ( 100 ), department VARCHAR ( 50 ), salary FLOAT ); Database Connection (db.php) <?php $conn = mysqli_connect ( "localhost" , "root" , "" , "employee_db" ); if (! $conn ) { die ( "Database Connection Failed" ); } ?> i) Employee Registration Form (register.php) < form method = "post" > Name: < input type = "text" name = "name" > < br > Email: < input type = "email" name = "email" > < br > Password: < input type = "password" name = "password" > < br > Department: < input type = "text" name = "department...

Practical - 9 IWD

  Aim: Information passing using Hidden variables (POST method) Page–1: Send data using hidden variable File Name: page1.php <!DOCTYPE html> <html> <head> <title>Page 1 </title> </head> <body> <h2>Enter Employee Name</h2> <form method= "post" action= "page2.php" > Employee Name: <input type= "text" name= "empname" ><br><br> <input type= "hidden" name= "company" value= "ABC Technologies" > <input type= "submit" value= "Send" > </form> </body> </html> Page–2: Receive hidden variable data File Name: page2.php <!DOCTYPE html> <html> <head> <title>Page 2 </title> </head> <body> <h2>Received Information</h2> <?php echo "Employee Name: " . $_POST [ 'empname' ] . "<br>...

Practical - 8 IWD

  Aim: Create a web page using a form to collect employee information File Name: employee_form.php <!DOCTYPE html> <html> <head> <title>Employee Information Form</title> </head> <body> <h2>Employee Information Form</h2> <form method= "post" action= "" > Employee ID: <input type= "text" name= "empid" ><br><br> Employee Name: <input type= "text" name= "empname" ><br><br> Department: <input type= "text" name= "dept" ><br><br> Salary: <input type= "text" name= "salary" ><br><br> <input type= "submit" name= "submit" value= "Submit" > </form> <?php if ( isset ( $_POST [ 'submit' ])) { echo "<h3>Employee Details</h3>" ; echo "Employee ID...

Practical - 7 IWD

  Aim: Demonstrate Single Inheritance in PHP Program <?php // Parent class class Animal { public function sound ( ) { echo "Animals make sounds." ; } } // Child class (single inheritance) class Dog extends Animal { public function sound ( ) { echo "Dog barks." ; } } // Object creation $dog = new Dog (); // Calling method $dog -> sound (); ?> Animal is the parent (base) class . Dog is the child (derived) class . Dog inherits the Animal class using extends . This demonstrates single inheritance (one parent → one child).

Practical - 6 IWD

  Aim : Demonstrate a simple abstract class Program <?php // Abstract class abstract class Shape { abstract public function calculateArea ( ); } // Child class class Rectangle extends Shape { private $length ; private $width ; public function __construct ( $l , $w ) { $this ->length = $l ; $this ->width = $w ; } public function calculateArea ( ) { return $this ->length * $this ->width; } } // Object creation $rect = new Rectangle ( 10 , 5 ); // Display output echo "Area of Rectangle: " . $rect -> calculateArea (); ?> abstract class cannot be instantiated directly. Abstract methods must be implemented in the child class. Demonstrates abstraction and inheritance .

Practical - 5 IWD

  Aim 1(a): Check if the given string is in lowercase Program <?php $string = "hello world" ; if ( $string === strtolower ( $string )) { echo "The given string is in lowercase." ; } else { echo "The given string is NOT in lowercase." ; } ?> strtolower() converts a string to lowercase. If the original string and lowercase string are the same, it means the string is already in lowercase. Aim 1(b): Replace a given word from the given string Program <?php $string = "PHP is a powerful scripting language" ; $search = "powerful" ; $replace = "popular" ; $newString = str_replace ( $search , $replace , $string ); echo "Original String: " . $string . "<br>" ; echo "Modified String: " . $newString ; ?> str_replace() replaces a word or part of a string with another word. The function does not change the original string; it returns a new o...