SlideShare a Scribd company logo
1 Strings
2 Arrays
3 Functions
4 Generic controls
5 Advanced Controls
6 Client-Slide Data Validation
7 Accessing the Database
8 Sessions and Cookies
9 E-mail functions
10 Drawing Shapes
11 Angular JS with controls
12 Angular JS Directives
Ex No :1 STRING FUNCTIONS
Aim :
To create a web page to perform string manipulation using PHP built-in string functions.
Algorithm :
Step1: Start.
Step2: Open the text editor and create a php file to perform the following string manipulations.
Step3: Find the length of a given string using strlen() function.
Step4: Print the position of a substring in a given string using strops() function.
Step5: Perform string replace using substr_replace() function.
Step6: Print the character of the given ASCII codes using chr() function.
Step7: Converting first letter to uppercase is done by ucfirst() function.
Step8: Conversion to uppercase is done by strtoupper() function.
Step9: Conversion to lowercase is done by strtolower() function.
Step10: Perform trimming of blank spaces using trim() function.
Step11: Perform string reverse using strrev() function.
Step12: Find the number of occurrences of a substring using substr_count() function.
Step13: Stop.
Program:
“srting.php”
<html>
<head>
<title>
String Functions
</title>
</head>
<body>
<h1> String Functions</h1>
<?php
echo "The test string is 'Hello World'.<br>";
echo "String Length= ",strlen("Hello World"),"<br>";
echo "The substring is at position",strpos("Hello World","World"),"<br>";
echo "Replacing 'Hello' with 'Hi'gives:", substr_replace("Hello World","Hi",0,4),"<br>";
echo "Using ASCII codes:",chr(65),chr(66),"<br>";
echo "Converting first letter to Uppercase :",ucfirst("hello world"),"<br>";
echo "Upper case conversion",strtoupper("hello world"),"<br>";
echo "Lower case conversion",strtolower("HELLO WORLD"),"<br>";
echo "'&nbsp;&nbsp;&nbsp;&nbsp;Hello World' after trimming is:",trim(" Hello
World"),"<br>";
echo "Reversed String is:",strrev("Hello World"),"<br>";
echo "Number of occurance of 'l' is:",substr_count("Hello World","l"),"<br>";
?>
</body>
</html>
Output:
Result:
Thus the string manipulations are performed successfully using PHP built-in string functions.
Ex No : 2 ARRAYS
Aim :
To write a PHP program to demonstrate the usage of arrays and its functions.
Algorithm :
Step1 : Start.
Step2: Declare the array $a and assign values (20,10,40,30,50,20) to it.
Step3: Declare the array $b and assign values (1,2,3,4,5,6) to it.
Step4: Declare the array $first and assign values ("apple","orange","mango") to it.
Step5: Declare the array $second and assign values ("mango","apple") to it.
Step7: The print_r() function is used to print the respective arrays.
Step8: The array_combine() is used to combine 2 arrays.
Step9: The array_count_values() function is used to display the total number of times each element
is present in the array.
Step10: The array_diff() function is used to display the difference between 2 arrays.
Step11: The array_intersect() function is used to display the intersecting elements of the 2 arrays.
Step12: The array_merge() function is used to merge 2 arrays together into a single array.
Step13: The array_push() function is used to add a new element to the array at the end of the array.
Step14: The array_pop() function is used to delete the last element of the array.
Step15: The count () function is used to display the total number of elements present in the array.
Step16: The array_sum() function is used to calculate and display the sum of elements present in
the array.
Step17: The asort() function is used to sort the array elements in ascending order.
Step18: The rsort() function is used to sort the array elements in reverse order.
Step19: Stop.
Program:
“arrays.php”
<html>
<head>
<title> Arrays </title>
</head>
<body>
<h1> Working with Arrays </h1>
<?php
$a= array(20,10,40,30,50,20);
$b= array(1,2,3,4,5,6);
$first=array("apple","orange","mango");
$second=array("mango","apple");
echo "<br>Array a: <br>";
print_r($a);
echo "<br>Array b: <br>";
print_r($b);
echo "<br>array_combine() function: <br>";
$c=array_combine($b,$a);
echo "<br>Array c: <br>";
print_r($c);
echo "<br>array_count_values() function: <br>";
print_r(array_count_values($a));
echo "<br>array_diff() function: <br>";
print_r(array_diff($first,$second));
echo "<br>array_intersect() function: <br>";
print_r(array_intersect($first,$second));
echo "<br>array_merge() function: <br>";
print_r(array_merge($a,$b));
echo "<br>array_push() function: <br>";
echo "Values of second array: Before insertion:<br>";
print_r($second);
echo "<br>Values of second array: After insertion:<br>";
print_r(array_push($second,"grapes"));
print_r("<br>");
print_r($second);
echo "<br>array_pop() function: <br>";
echo "Values of second array: Before deletion:<br>";
print_r($second);
echo "<br>Values of second array: After deletion:<br>";
print_r(array_pop($second));
print_r("<br>");
print_r($second);
echo "<br>Number of elements in Array b :",count($b),"<br>";
echo " <br>Sum of elements in the Array b:",array_sum($b),"<br>";
echo "<br>Array sorting:<br>";
asort($a);
print_r($a);
echo "<br>Array Reverse sorting:<br>";
rsort($a);
print_r($a);
?>
</body>
</html>
Output:
Result:
Thus the PHP program to demonstrate the usage of arrays and its functions are executed
successfully.
Ex No : 3 FUNCTIONS
Aim :
To create a web page to find factorial of a number using user-defined functions in PHP.
Algorithm :
Step 1 : Start
Step 2 : To create a web page with a form containing a text box and a submit button.
Step 3 : Read the value of n from the text box using “POST” method in PHP function.
Step 4: Find factorial for n using the user-defined function factorial().
Step 5: Print the result .
Step 6 : Stop
Program:
“function.php”
<html>
<head>
<title>Factorial Program using loop in PHP</title>
</head>
<body>
<form method="post">
Enter the Number:<br>
<input type="number" name="number" id="number">
<input type="submit" name="submit" value="Submit" />
</form>
<?php
function factorial()
{
if($_POST)
{
$fact = 1;
$number = $_POST['number'];
if($number<0)
{
echo "Invalid Number.";
exit;
}
for ($i = 1; $i <= $number; $i++)
{
$fact = $fact * $i;
}
echo "Factorial of $number:<br><br>";
echo $fact . "<br>";
}
}
factorial();
?>
</body>
</html>
Output:
Result:
Thus the factorial of a number is calculated using user-defined functions in PHP.
Ex No : 3.1
Aim:
To generate an employee payslip using class and object concept in PHP.
Algorithm:
Step 1: Start
Step 2: Define the class ‘person’ with its members
Step 3: Initialize the values for $name,$id,$age and $bpay by using get() function.
Step 4: Calculate allowances ($ta & $da) and deductions ($lic & $pf). Also calculate the netpay
$netpay by using calculate function.
Step 5: Print the payslip using display() function.
Step 6: Stop
Program:
“class.php”
<html>
<body>
<?php
class person
{
public $name;
public $id;
public $age;
public $bpay;
public $da;
public $ta;
public $pf;
public $lic;
public $netpay;
function get($name,$id,$age,$bpay)
{
$this->name=$name;
$this->id=$id;
$this->age=$age;
$this->bpay=$bpay;
}
function calculate()
{
$da=$this->bpay*0.4;
echo "<br> DA=Rs.",$da;
$ta=$this->bpay*0.2;
echo "<br> TA=Rs.",$ta;
$pf=$this->bpay*0.2;
echo "<br> PF=Rs.",$pf;
$lic=$this->bpay*0.2;
echo "<br> LIC=Rs.",$lic;
$netpay=$this->bpay+($da+$ta)-($pf+$lic);
echo "<br> NET SALARY=Rs.",$netpay;
}
function display()
{
echo"Employee Details<br>";
echo "<br>NAME=",$this->name;
echo "<br>ID=",$this->id;
echo "<br>AGE=",$this->age;
echo "<br>BASIC PAY=Rs.",$this->bpay;
}
}
$r=new person();
$r->get('Priya','3','30','10000');
$r->display();
$r->calculate();
?>
</body>
</html>
Output:
Result:
Thus the employee payslip is generated successfully in PHP.
Ex.No: 4
Design and develop the user interface by using generic control in PHP.
Aim:
To design and develop a PHP web page for prepare the student result, grade and average of a
mark statement by using of generic control.
Algorithm:
Step 1 : Start the process
Step 2: Design the user interface in a HTML file.
Step 3: Use the FORM element and send user inputs to server.
Step 4 : Develop the PHP script for read the user entered values.
Sept 5: Use the $_REQUEST PHP variable for and store the input.
Sept 6: Save the files .HTML and .PHP extension.
Step 7: Display the output in the Browser
Step 8: Stop the process
HTML Design
.HMTL
<html>
<h1><center>Student Mark Statement</center></h1>
<body>
Enter The Data
<form action="191ca003 6.php" method="get">
ENTER REG NO :
<input type="text" name="Regno">
<br>
ENTER SUBJECT 1 MARK:
<input type="text" name="m1">
<br>
ENTER SUBJECT 2 MARK:
<input type="text" name="m2">
<br>
ENTER SUBJECT 3 MARK:
<input type="text" name="m3">
<br>
ENTER SUBJECT 4 MARK:
<input type="text" name="m4">
<br>
ENTER SUBJECT 5 MARK:
<input type="text" name="m5">
<br>
<input type="checkbox" name="tl">
:TOTAL
<input type="checkbox" name="PF">
:RESULT
<input type="checkbox" name="G">
:AVERAGE
<br>
<center><input type="submit" value="SUBMIT"></center>
</form>
</body>
</html>
Php script
.PHP
<html>
<body>
<h1><center> STUDENT RESULT </center></h1>
<?php
$regno=$_REQUEST["Regno"];
echo "REG NO :".$regno;
echo "<br>";
$a=$_REQUEST["m1"];
$b=$_REQUEST["m2"];
$c=$_REQUEST["m3"];
$d=$_REQUEST["m4"];
$e=$_REQUEST["m5"];
$total=$a+$b+$c+$d+$e;
if(isset($_REQUEST["tl"]))
echo ("TOTAL :".$total);
echo"<br>";
if(isset($_REQUEST["PF"]))
{ echo"RESULT :";
if($a>=35&&$b>=35&&$c>=35&&$d>=35&&$e>=35)
echo " PASS ";
else
echo"FAIL";
}
echo "<br>";
if(isset($_REQUEST["G"]))
{
echo ("AVERAGE : ".$total/5);
echo "<br>";
}
if ($total<280&&$total>=250)
echo"GRADE A";
else if($total<250&&$total>=200)
echo "GRADE B";
else
echo " GRADE C";
?>
</body>
</html>
Output:
Result:
Thus the above student mark entry user interface HTML design and producing the result PHP
script has been successfully designed and displays the output.
Ex.No : 5
Design and develop the user interface by using advanced control in PHP.
Aim:
To design and develop a web page for hotel room booking user interface by using of generic
control.
Algorithm:
Step 1 : Start the process
Step 2: Design the user interface in a HTML file with advanced controls.
Step 3: Use the FORM element and send user inputs to server.
Step 4 : Develop the PHP script for read the user entered values.
Sept 5: Use the $_REQUEST PHP variable for and store the input.
Sept 6: Save the files .HTML and .PHP extension.
Step 7: Display the output in the Browser
Step 8: Stop the process
HTML Design
.HMTL
<html>
<body bgcolor="#FFFFBB">
<img src="hotel123.jpg" width="100%" height="25%">
</img>
<center>
<table border="1" style="font-size:30">
<tr style="color:red">
<td bgcolor="green" colspan="2">
<h1><center> ROOM BOOKING </center></h1>
</td>
</tr>
<form method="post" action="191ca0037.php" >
<tr bgcolor="yellow">
<td>
ARRIVAL :
</td>
<td>
DEPATURE :
</td>
</tr>
<tr>
<td>
<input type="datetime-local" name="c1">
</td>
<td>
<input type="datetime-local" name="c2">
</td>
</tr>
<tr bgcolor="yellow">
<td>
No.Of.Adults :
</td>
<td>
No.Of.Childrens :
</td>
</tr>
<tr>
<td>
<Select name="adults">
<option>1</option>
<option>2</option>
<option>3</option>
<option>4</option>
<option>5</option>
</select>
</td>
<td>
<Select name="children">
<option>0</option>
<option>1</option>
<option>2</option>
<option>3</option>
<option>4</option>
<option>5</option>
</select>
</td>
</tr>
<tr>
<td bgcolor="yellow">
No.Of.Rooms :
</td>
<td>
<input type="text" name="room">
</td>
</tr>
<tr>
<td bgcolor="yellow">
ROOM TYPE :
</td>
<td bgcolor="white">
<input type="radio" value="DELUX" name="type1">
DELUX
<br>
<input type="radio" value="A/C" name="type1">
A/C
<br>
<input type="radio" value="NON A/C" name="type1">
NON A/C
</td>
</tr>
<tr>
<td bgcolor="yellow">
Mode Of Payment
</td>
<td bgcolor="white">
<input type="radio" value= "CASH" name="pay">
CASH
<input type="radio" value="CARD" name="pay">
CARD
</td>
</tr>
<tr>
<td bgcolor="yellow">
Maid ID:
</td>
<td>
<input type="text" name="id">
</td>
</tr>
<tr>
<td bgcolor="yellow">
Contact No :
</td>
<td>
<input type="text" name="no">
</td>
</tr>
<tr><td colspan="2">
<center><input type="submit" value="BOOK MY ROOM"></center>
</td>
</tr>
</table>
</center>
</body>
</html>
Php script
.PHP
<?php
echo "<font color='RED'>";
echo"<center>BOOKING CONFIRMATION</center>";
echo "</font>";
echo "<br>";
echo "<br>";
echo "<font color='BLUE'>";
echo"From : ";
$adate=date_create($_REQUEST["c1"]);
echo date_format($adate,'d-m-Y');
echo"To:";
$ddate=date_create($_REQUEST["c2"]);
echo date_format($ddate,'d-m-Y');
echo "<br>";
echo "<br>";
echo (" No of Rooms :".$_REQUEST["room"]);
echo "<br>";
echo "<br>";
$adult=$_REQUEST["adults"];
$child=$_REQUEST["children"];
echo ($_REQUEST["type1"]." ROOM BOOKED FOR ".$adult." ADULT ".$child." CHILDREN");
echo "<br>";
echo "<br>";
echo ("YOUR PAYEMENT IS COMPLETED SUCCESSFULLY AND YOUR PAYMENT MODE IS
".$_REQUEST["pay"]);
echo "<br>";
echo "<br>";
echo("THE CONFIRMATION SEND TO THE FOLLOWING MAIL ID : ");
echo"<font color='RED'>";
echo($_REQUEST["id"]);
echo "</font>";
echo "OR CONTACT NO : " ;
echo"<font color='RED'>";
echo($_REQUEST["no"]);
echo "</font>"
?>
Output:
Result:
Thus the above hotel room booking user interface HTML design and producing the
confirmation PHP script has been successfully designed and displays the output.
Ex No : 6 CLIENT-SLIDE DATA VALIDATION
Aim :
To demonstrate form validation in PHP.
Algorithm :
Step 1 : Start.
Step 2 : To create a web page with required controls to get user registration details
Step 3 : Read user inputs using GET/POST in PHP program.
Step 4: Perform data validation by using isempty() , filter_var() functions.
Step 5: Display validation notification.
Step 6 : Stop.
Program:
“formvalidation.php”
<html>
<head>
<style> .error
{
color:#FF0000;
}
</style>
</head>
<body>
<?php
$nameerr=$emailerr=$gendererr=" ";
$name=$email=$gender=$department=" ";
if($_SERVER["REQUEST_METHOD"]=="POST")
{
if(empty($_POST["name"]))
{
$nameerr="Name is Required";
}
else
{
$name=$_POST["name"];
}
if(empty($_POST["email"]))
{
$emailerr="Email is Required";
}
else
{
$email=$_POST["email"];
if(!filter_var($email,FILTER_VALIDATE_EMAIL))
{
$emailerr="Invalid Email format";
}
}
if(empty($_POST["department"]))
{
$department="";
}
else
{
$department=$_POST["department"];
}
if(empty($_POST["gender"]))
{
$gendererr="Gender is Required";
}
else
{
$gender=$_POST["gender"];
}
}
?>
<h2> Registration Form</h2>
<p> <span class="error">*required field.</span></p>
<form method="POST">
<table>
<tr>
<td>Name:</td>
<td><input type="text" name="name">
<span class="error">*
<?php
echo $nameerr;
?>
</span>
</td>
</tr>
<tr>
<td>Email:</td>
<td ><input type="text" name="email">
<span class="error">*
<?php
echo $emailerr;
?>
</span>
</td>
</tr>
<tr>
<td>Department:</td>
<td><input type="text" name="department">
</td>
</tr>
<tr>
<td>Gender:</td>
<td>
<input type="radio" name="gender" value="female">female
<input type="radio" name="gender" value="male">male
<span class="error">*
<?php
echo $gendererr;
?>
</span>
</td>
</tr>
<td><input type="submit" name="submit" value="submit">
</td>
</table>
</form>
<?php
echo "<h2> Your Given Details: </h2><br>";
echo $name,"<br>",$email,"<br>",$department,"<br>",$gender;
?>
</body>
</html>
Output:
Result:
Thus the form validation is performed successfully in PHP.
Exercise: 7
Date :
Develop a PHP application for MYSQL database connection.
Aim:
To develop a student data retrieval page in PHP.
Algorithm:
Step 1 : Start the process
Step 2: Create the MYSQL database.
Step 3: Create the student table in MYSQL database.
Step 4: Insert the values to the student table.
Sept 5: Create the connection object using mysqli().
Sept 6: Retrieve the data from the table using SELECT query.
Step 7: Display the output each in retrieved row in the Browser.
Step 8: Close the MYSQL connection.
Step 9: Stop the process
.PHP
<?php
$conn=new mysqli("192.168.24.191","student","student","191ca003db");
if(!$conn){
die('COULD NOT CONNECTED;'.mysql_error());
}
echo('CONNECTED SUCCESSFULLY');
ECHO"<BR>";
ECHO"<BR>";
$a="select*from mytable3";
$result=$conn->query($a);
if($result->num_rows>0){
while($row=$result->fetch_assoc()){
echo"NAME:".$row["name"]."-ROLL NO:".$row["rno"]."<br>";
}
}else
{
echo"0 results";
}
mysqli_close($conn);
?>
OUTPUT:
Result:
Thus the above MYSQL database connection to the PHP application has been successfully
designed and displays the output.
Exercise: 8
Date :
Develop a PHP script with Session and Cookie.
Aim:
To develop a College home page for display the visit count using session and cookie in PHP.
Algorithm:
Step 1 : Start the process
Step 2: Design the college home page.
Step 3: Set the cookies value using setcookie().
Step 4: Use the $_COOKIE variable for store the value.
Step 5: Display the total number of visits.
Step 6: Stop the process
.PHP
<html>
<head>
<title>PHP CODE TO COUNT NUMBER OF VISITORS USING COOKIES </title>
</head>
<h1><center>WELCOME TO DR.N.G.P ARTS AND SCIENCE COLLEGE</center></h1>
<ul>COURSES
<li>BCA</li>
<li>BBA</li>
<li>B.Sc(CS)</li>
<li>B.Com</li>
<li>B.Sc(IT)</li>
</ul>
<?php
if(!isset($_COOKIE['count'])){
echo"WELCOME THIS IS THE FIRST TIME YOU VIEWED THIS PAGE";
$cookie=1;
setcookie("count",$cookie);
}
else
{
$cookie=++$_COOKIE['count'];
setcookie ("count",$cookie);
echo "YOU HAVE VIEWED THIS PAGE ".$_COOKIE['count']."TIMES";
}
?>
</BODY>
</html>
OUTPUT:
Result:
Thus the above college home page number of visit application using session and cookie value
has been successfully designed and displays the output.
Exercise: 9
Date :
Develop a PHP application for send an Email.
Aim:
To develop a PHP application to send a leave email.
Algorithm:
Step 1 : Start the process.
Step 2: Define the mail properties.
Step 3: Set the cookies value using setcookie().
Step 4: Use the $_COOKIE variable for store the value.
Step 5: Display the total number of visits.
Step 6: Stop the process.
.PHP
<html>
<head>
<title>SENDING HTML EMAIL USING PHP</title>
</head>
<body>
<?php
$to="191ca003@drngpasc.ac.in";
$subject="LEAVE REQUEST";
$message=("<b>I AM REQUESTING LEAVE ON 10/05/2022"."<H1>AKASH P </h1>");
$header=("From:bca2022@gmail.comrn"."MINE-Version: 1.0rn"."Content-type:
text/htmlrn");
$retval=mail ($to,$subject,$message,$header);
if($retval == true)
echo"MESSAGE SENT SUCCESSFULLY.....";
else
echo"MESSAGE COULD NOT SENT....";
?>
</BODY>
</html>
OUTPUT:
Result:
Thus the above leave email PHP script has been successfully designed and displays the output.
Exercise: 10
Date :
Create a PNG file with different shapes.
Aim:
To Create PHP web page to display the different shapes in a PNG.
Algorithm:
Step 1 : Start the process
Step 2: Define image size using imagecreate().
Step 3: Set the color of the images using imagecolorallocate().
Step 4: Use the different image function for forming the shapes in the PNG.
Step 5: Display the shapes with PNG in PHP.
Step 6: Stop the process
.PHP
<?php
header('content-type:image/png');
$png_image=imagecreate(300,300);
$grey=imagecolorallocate($png_image,229,229,229);
$green=imagecolorallocate($png_image,128,204,204);
imagefilltoborder($png_image,0,0,$grey,$grey);
imagefilledrectangle($png_image,20,20,80,80,$green);
imagefilledrectangle($png_image,100,20,280,80,$green);
imagefilledellipse($png_image,50,150,75,75,$green);
imagefilledellipse($png_image,200,150,150,75,$green);
$poly_points=array(150,200,100,280,200,280);
imagefilledpolygon($png_image,$poly_points,3,$green);
imagepng($png_image);
imagedestroy($png_image);
?>
OUTPUT:
Result:
Thus the above different shapes with PNG image in PNP has been successfully designed and
displays the output.
Exercise: 11
Aim:
To display the concatenation of the first and second input of a user using Angular JS.
Algorithm:
Step 1 : Start the process
Step 2: Create two label and two textbox for getting input from user.
Step 3: Concatenated the two string
Step 4: Display the output
Step 5: Stop the process
PROGRAM
<html>
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.6.9/angular.min.js"></script>
<body>
<div ng-app="myApp" ng-controller="myCtrl">
First Name: <input type="text" ng-model="firstName"><br>
Last Name: <input type="text" ng-model="lastName"><br>
<br>
Full Name: {{firstName + " " + lastName}}
</div>
<script>
var app = angular.module('myApp', []);
app.controller('myCtrl', function($scope) {
$scope.firstName = "John";
$scope.lastName = "Doe";
});
</script>
</body>
</html>
OUTPUT

More Related Content

PDF
개발자를 위한 (블로그) 글쓰기 intro
PDF
An introduction to MongoDB
PPTX
Psycopg2 - Connect to PostgreSQL using Python Script
PPTX
[DevGround] 린하게 구축하는 스타트업 데이터파이프라인
PDF
대용량 로그분석 Bigquery로 간단히 사용하기 (20170215 T아카데미)
PDF
Event source 학습 내용 공유
PDF
[Pgday.Seoul 2020] SQL Tuning
PDF
Inno db internals innodb file formats and source code structure
개발자를 위한 (블로그) 글쓰기 intro
An introduction to MongoDB
Psycopg2 - Connect to PostgreSQL using Python Script
[DevGround] 린하게 구축하는 스타트업 데이터파이프라인
대용량 로그분석 Bigquery로 간단히 사용하기 (20170215 T아카데미)
Event source 학습 내용 공유
[Pgday.Seoul 2020] SQL Tuning
Inno db internals innodb file formats and source code structure

What's hot (17)

PPTX
DB 모니터링 신규 & 개선 기능 (박명규)
PDF
What is new in PostgreSQL 14?
PDF
[Pgday.Seoul 2017] 8. PostgreSQL 10 새기능 소개 - 김상기
PDF
빅데이터 처리기술의 이해
PPTX
Cfgmgmtcamp 2023 — eBPF Superpowers
PPTX
Overview SQL Server 2019
PDF
PostgreSQL: Advanced indexing
PPTX
Azure databases for PostgreSQL, MySQL and MariaDB
PDF
Bash Script Disk Space Utilization Report and EMail
PDF
[Pgday.Seoul 2017] 6. GIN vs GiST 인덱스 이야기 - 박진우
PDF
OpenStack Trove 技術解説
PDF
Little Big Data #1. 바닥부터 시작하는 데이터 인프라
PDF
Helping Searchers Satisfice through Query Understanding
PPTX
산동네 게임 DBA 이야기
PDF
Data Science. Intro
PDF
MySQL Administrator 2021 - 네오클로바
PDF
MySQL for beginners
DB 모니터링 신규 & 개선 기능 (박명규)
What is new in PostgreSQL 14?
[Pgday.Seoul 2017] 8. PostgreSQL 10 새기능 소개 - 김상기
빅데이터 처리기술의 이해
Cfgmgmtcamp 2023 — eBPF Superpowers
Overview SQL Server 2019
PostgreSQL: Advanced indexing
Azure databases for PostgreSQL, MySQL and MariaDB
Bash Script Disk Space Utilization Report and EMail
[Pgday.Seoul 2017] 6. GIN vs GiST 인덱스 이야기 - 박진우
OpenStack Trove 技術解説
Little Big Data #1. 바닥부터 시작하는 데이터 인프라
Helping Searchers Satisfice through Query Understanding
산동네 게임 DBA 이야기
Data Science. Intro
MySQL Administrator 2021 - 네오클로바
MySQL for beginners
Ad

Similar to PHP record- with all programs and output (20)

PPTX
Php functions
PDF
Php tips-and-tricks4128
PPTX
Chapter 2 wbp.pptx
PPT
Php my sql - functions - arrays - tutorial - programmerblog.net
PPTX
PHP Functions & Arrays
PPT
Web Technology_10.ppt
PDF
Lithium: The Framework for People Who Hate Frameworks
PPTX
Php & my sql
PPTX
Regular expressions, Session and Cookies by Dr.C.R.Dhivyaa Kongu Engineering ...
PPTX
UNIT IV (4).pptx
PDF
From mysql to MongoDB(MongoDB2011北京交流会)
KEY
Can't Miss Features of PHP 5.3 and 5.4
PPTX
Array functions for all languages prog.pptx
PPTX
Array functions using php programming language.pptx
KEY
Good Evils In Perl (Yapc Asia)
PPT
An Elephant of a Different Colour: Hack
PDF
20 modules i haven't yet talked about
PDF
The State of Lithium
PDF
Top 10 php classic traps
Php functions
Php tips-and-tricks4128
Chapter 2 wbp.pptx
Php my sql - functions - arrays - tutorial - programmerblog.net
PHP Functions & Arrays
Web Technology_10.ppt
Lithium: The Framework for People Who Hate Frameworks
Php & my sql
Regular expressions, Session and Cookies by Dr.C.R.Dhivyaa Kongu Engineering ...
UNIT IV (4).pptx
From mysql to MongoDB(MongoDB2011北京交流会)
Can't Miss Features of PHP 5.3 and 5.4
Array functions for all languages prog.pptx
Array functions using php programming language.pptx
Good Evils In Perl (Yapc Asia)
An Elephant of a Different Colour: Hack
20 modules i haven't yet talked about
The State of Lithium
Top 10 php classic traps
Ad

More from KavithaK23 (10)

DOCX
PHP Lab template for lecturer log book- and syllabus
DOCX
CRUD OPERATIONS using MySQL connectivity in php
PDF
unit 3.pdf
DOCX
Unit III.docx
DOCX
Unit 4 - 2.docx
PDF
unit 4 - 1.pdf
PDF
unit 5 -2.pdf
PDF
unit 5 -1.pdf
DOCX
UNIT 5.docx
PDF
unit 2 -program security.pdf
PHP Lab template for lecturer log book- and syllabus
CRUD OPERATIONS using MySQL connectivity in php
unit 3.pdf
Unit III.docx
Unit 4 - 2.docx
unit 4 - 1.pdf
unit 5 -2.pdf
unit 5 -1.pdf
UNIT 5.docx
unit 2 -program security.pdf

Recently uploaded (20)

PDF
Network Security Unit 5.pdf for BCA BBA.
PPTX
Big Data Technologies - Introduction.pptx
PPTX
20250228 LYD VKU AI Blended-Learning.pptx
PDF
Encapsulation theory and applications.pdf
PDF
Per capita expenditure prediction using model stacking based on satellite ima...
PPTX
Spectroscopy.pptx food analysis technology
PDF
Optimiser vos workloads AI/ML sur Amazon EC2 et AWS Graviton
PDF
Blue Purple Modern Animated Computer Science Presentation.pdf.pdf
PPTX
Digital-Transformation-Roadmap-for-Companies.pptx
PPTX
KOM of Painting work and Equipment Insulation REV00 update 25-dec.pptx
PPTX
Programs and apps: productivity, graphics, security and other tools
PPTX
Understanding_Digital_Forensics_Presentation.pptx
PPTX
Cloud computing and distributed systems.
PPT
“AI and Expert System Decision Support & Business Intelligence Systems”
PDF
Encapsulation_ Review paper, used for researhc scholars
PDF
Mobile App Security Testing_ A Comprehensive Guide.pdf
PDF
Review of recent advances in non-invasive hemoglobin estimation
PPTX
Effective Security Operations Center (SOC) A Modern, Strategic, and Threat-In...
PPTX
ACSFv1EN-58255 AWS Academy Cloud Security Foundations.pptx
PDF
Unlocking AI with Model Context Protocol (MCP)
Network Security Unit 5.pdf for BCA BBA.
Big Data Technologies - Introduction.pptx
20250228 LYD VKU AI Blended-Learning.pptx
Encapsulation theory and applications.pdf
Per capita expenditure prediction using model stacking based on satellite ima...
Spectroscopy.pptx food analysis technology
Optimiser vos workloads AI/ML sur Amazon EC2 et AWS Graviton
Blue Purple Modern Animated Computer Science Presentation.pdf.pdf
Digital-Transformation-Roadmap-for-Companies.pptx
KOM of Painting work and Equipment Insulation REV00 update 25-dec.pptx
Programs and apps: productivity, graphics, security and other tools
Understanding_Digital_Forensics_Presentation.pptx
Cloud computing and distributed systems.
“AI and Expert System Decision Support & Business Intelligence Systems”
Encapsulation_ Review paper, used for researhc scholars
Mobile App Security Testing_ A Comprehensive Guide.pdf
Review of recent advances in non-invasive hemoglobin estimation
Effective Security Operations Center (SOC) A Modern, Strategic, and Threat-In...
ACSFv1EN-58255 AWS Academy Cloud Security Foundations.pptx
Unlocking AI with Model Context Protocol (MCP)

PHP record- with all programs and output

  • 1. 1 Strings 2 Arrays 3 Functions 4 Generic controls 5 Advanced Controls 6 Client-Slide Data Validation 7 Accessing the Database 8 Sessions and Cookies 9 E-mail functions 10 Drawing Shapes 11 Angular JS with controls 12 Angular JS Directives Ex No :1 STRING FUNCTIONS Aim : To create a web page to perform string manipulation using PHP built-in string functions. Algorithm : Step1: Start. Step2: Open the text editor and create a php file to perform the following string manipulations. Step3: Find the length of a given string using strlen() function. Step4: Print the position of a substring in a given string using strops() function. Step5: Perform string replace using substr_replace() function. Step6: Print the character of the given ASCII codes using chr() function. Step7: Converting first letter to uppercase is done by ucfirst() function. Step8: Conversion to uppercase is done by strtoupper() function. Step9: Conversion to lowercase is done by strtolower() function.
  • 2. Step10: Perform trimming of blank spaces using trim() function. Step11: Perform string reverse using strrev() function. Step12: Find the number of occurrences of a substring using substr_count() function. Step13: Stop. Program: “srting.php” <html> <head> <title> String Functions </title> </head> <body> <h1> String Functions</h1> <?php echo "The test string is 'Hello World'.<br>"; echo "String Length= ",strlen("Hello World"),"<br>"; echo "The substring is at position",strpos("Hello World","World"),"<br>"; echo "Replacing 'Hello' with 'Hi'gives:", substr_replace("Hello World","Hi",0,4),"<br>"; echo "Using ASCII codes:",chr(65),chr(66),"<br>"; echo "Converting first letter to Uppercase :",ucfirst("hello world"),"<br>"; echo "Upper case conversion",strtoupper("hello world"),"<br>"; echo "Lower case conversion",strtolower("HELLO WORLD"),"<br>";
  • 3. echo "'&nbsp;&nbsp;&nbsp;&nbsp;Hello World' after trimming is:",trim(" Hello World"),"<br>"; echo "Reversed String is:",strrev("Hello World"),"<br>"; echo "Number of occurance of 'l' is:",substr_count("Hello World","l"),"<br>"; ?> </body> </html> Output: Result: Thus the string manipulations are performed successfully using PHP built-in string functions.
  • 4. Ex No : 2 ARRAYS Aim : To write a PHP program to demonstrate the usage of arrays and its functions. Algorithm : Step1 : Start. Step2: Declare the array $a and assign values (20,10,40,30,50,20) to it. Step3: Declare the array $b and assign values (1,2,3,4,5,6) to it. Step4: Declare the array $first and assign values ("apple","orange","mango") to it. Step5: Declare the array $second and assign values ("mango","apple") to it. Step7: The print_r() function is used to print the respective arrays. Step8: The array_combine() is used to combine 2 arrays. Step9: The array_count_values() function is used to display the total number of times each element is present in the array. Step10: The array_diff() function is used to display the difference between 2 arrays. Step11: The array_intersect() function is used to display the intersecting elements of the 2 arrays. Step12: The array_merge() function is used to merge 2 arrays together into a single array. Step13: The array_push() function is used to add a new element to the array at the end of the array. Step14: The array_pop() function is used to delete the last element of the array. Step15: The count () function is used to display the total number of elements present in the array. Step16: The array_sum() function is used to calculate and display the sum of elements present in the array. Step17: The asort() function is used to sort the array elements in ascending order. Step18: The rsort() function is used to sort the array elements in reverse order. Step19: Stop.
  • 5. Program: “arrays.php” <html> <head> <title> Arrays </title> </head> <body> <h1> Working with Arrays </h1> <?php $a= array(20,10,40,30,50,20); $b= array(1,2,3,4,5,6); $first=array("apple","orange","mango"); $second=array("mango","apple"); echo "<br>Array a: <br>"; print_r($a); echo "<br>Array b: <br>"; print_r($b); echo "<br>array_combine() function: <br>"; $c=array_combine($b,$a); echo "<br>Array c: <br>"; print_r($c); echo "<br>array_count_values() function: <br>"; print_r(array_count_values($a)); echo "<br>array_diff() function: <br>"; print_r(array_diff($first,$second));
  • 6. echo "<br>array_intersect() function: <br>"; print_r(array_intersect($first,$second)); echo "<br>array_merge() function: <br>"; print_r(array_merge($a,$b)); echo "<br>array_push() function: <br>"; echo "Values of second array: Before insertion:<br>"; print_r($second); echo "<br>Values of second array: After insertion:<br>"; print_r(array_push($second,"grapes")); print_r("<br>"); print_r($second); echo "<br>array_pop() function: <br>"; echo "Values of second array: Before deletion:<br>"; print_r($second); echo "<br>Values of second array: After deletion:<br>"; print_r(array_pop($second)); print_r("<br>"); print_r($second); echo "<br>Number of elements in Array b :",count($b),"<br>"; echo " <br>Sum of elements in the Array b:",array_sum($b),"<br>"; echo "<br>Array sorting:<br>"; asort($a); print_r($a);
  • 7. echo "<br>Array Reverse sorting:<br>"; rsort($a); print_r($a); ?> </body> </html> Output: Result: Thus the PHP program to demonstrate the usage of arrays and its functions are executed successfully.
  • 8. Ex No : 3 FUNCTIONS Aim : To create a web page to find factorial of a number using user-defined functions in PHP. Algorithm : Step 1 : Start Step 2 : To create a web page with a form containing a text box and a submit button. Step 3 : Read the value of n from the text box using “POST” method in PHP function. Step 4: Find factorial for n using the user-defined function factorial(). Step 5: Print the result . Step 6 : Stop Program: “function.php” <html> <head> <title>Factorial Program using loop in PHP</title> </head> <body> <form method="post"> Enter the Number:<br> <input type="number" name="number" id="number"> <input type="submit" name="submit" value="Submit" /> </form> <?php function factorial() {
  • 9. if($_POST) { $fact = 1; $number = $_POST['number']; if($number<0) { echo "Invalid Number."; exit; } for ($i = 1; $i <= $number; $i++) { $fact = $fact * $i; } echo "Factorial of $number:<br><br>"; echo $fact . "<br>"; } } factorial(); ?> </body> </html> Output:
  • 10. Result: Thus the factorial of a number is calculated using user-defined functions in PHP.
  • 11. Ex No : 3.1 Aim: To generate an employee payslip using class and object concept in PHP. Algorithm: Step 1: Start Step 2: Define the class ‘person’ with its members Step 3: Initialize the values for $name,$id,$age and $bpay by using get() function. Step 4: Calculate allowances ($ta & $da) and deductions ($lic & $pf). Also calculate the netpay $netpay by using calculate function. Step 5: Print the payslip using display() function. Step 6: Stop Program: “class.php” <html> <body> <?php class person { public $name; public $id; public $age; public $bpay; public $da; public $ta;
  • 12. public $pf; public $lic; public $netpay; function get($name,$id,$age,$bpay) { $this->name=$name; $this->id=$id; $this->age=$age; $this->bpay=$bpay; } function calculate() { $da=$this->bpay*0.4; echo "<br> DA=Rs.",$da; $ta=$this->bpay*0.2; echo "<br> TA=Rs.",$ta; $pf=$this->bpay*0.2; echo "<br> PF=Rs.",$pf; $lic=$this->bpay*0.2; echo "<br> LIC=Rs.",$lic; $netpay=$this->bpay+($da+$ta)-($pf+$lic); echo "<br> NET SALARY=Rs.",$netpay; } function display()
  • 13. { echo"Employee Details<br>"; echo "<br>NAME=",$this->name; echo "<br>ID=",$this->id; echo "<br>AGE=",$this->age; echo "<br>BASIC PAY=Rs.",$this->bpay; } } $r=new person(); $r->get('Priya','3','30','10000'); $r->display(); $r->calculate(); ?> </body> </html> Output:
  • 14. Result: Thus the employee payslip is generated successfully in PHP.
  • 15. Ex.No: 4 Design and develop the user interface by using generic control in PHP. Aim: To design and develop a PHP web page for prepare the student result, grade and average of a mark statement by using of generic control. Algorithm: Step 1 : Start the process Step 2: Design the user interface in a HTML file. Step 3: Use the FORM element and send user inputs to server. Step 4 : Develop the PHP script for read the user entered values. Sept 5: Use the $_REQUEST PHP variable for and store the input. Sept 6: Save the files .HTML and .PHP extension. Step 7: Display the output in the Browser Step 8: Stop the process HTML Design .HMTL <html> <h1><center>Student Mark Statement</center></h1> <body> Enter The Data <form action="191ca003 6.php" method="get"> ENTER REG NO : <input type="text" name="Regno">
  • 16. <br> ENTER SUBJECT 1 MARK: <input type="text" name="m1"> <br> ENTER SUBJECT 2 MARK: <input type="text" name="m2"> <br> ENTER SUBJECT 3 MARK: <input type="text" name="m3"> <br> ENTER SUBJECT 4 MARK: <input type="text" name="m4"> <br> ENTER SUBJECT 5 MARK: <input type="text" name="m5"> <br> <input type="checkbox" name="tl"> :TOTAL <input type="checkbox" name="PF"> :RESULT <input type="checkbox" name="G"> :AVERAGE <br> <center><input type="submit" value="SUBMIT"></center>
  • 17. </form> </body> </html> Php script .PHP <html> <body> <h1><center> STUDENT RESULT </center></h1> <?php $regno=$_REQUEST["Regno"]; echo "REG NO :".$regno; echo "<br>"; $a=$_REQUEST["m1"]; $b=$_REQUEST["m2"]; $c=$_REQUEST["m3"]; $d=$_REQUEST["m4"]; $e=$_REQUEST["m5"]; $total=$a+$b+$c+$d+$e; if(isset($_REQUEST["tl"])) echo ("TOTAL :".$total); echo"<br>"; if(isset($_REQUEST["PF"])) { echo"RESULT :";
  • 18. if($a>=35&&$b>=35&&$c>=35&&$d>=35&&$e>=35) echo " PASS "; else echo"FAIL"; } echo "<br>"; if(isset($_REQUEST["G"])) { echo ("AVERAGE : ".$total/5); echo "<br>"; } if ($total<280&&$total>=250) echo"GRADE A"; else if($total<250&&$total>=200) echo "GRADE B"; else echo " GRADE C"; ?> </body> </html>
  • 19. Output: Result: Thus the above student mark entry user interface HTML design and producing the result PHP script has been successfully designed and displays the output.
  • 20. Ex.No : 5 Design and develop the user interface by using advanced control in PHP. Aim: To design and develop a web page for hotel room booking user interface by using of generic control. Algorithm: Step 1 : Start the process Step 2: Design the user interface in a HTML file with advanced controls. Step 3: Use the FORM element and send user inputs to server. Step 4 : Develop the PHP script for read the user entered values. Sept 5: Use the $_REQUEST PHP variable for and store the input. Sept 6: Save the files .HTML and .PHP extension. Step 7: Display the output in the Browser Step 8: Stop the process HTML Design .HMTL <html> <body bgcolor="#FFFFBB"> <img src="hotel123.jpg" width="100%" height="25%"> </img> <center> <table border="1" style="font-size:30"> <tr style="color:red">
  • 21. <td bgcolor="green" colspan="2"> <h1><center> ROOM BOOKING </center></h1> </td> </tr> <form method="post" action="191ca0037.php" > <tr bgcolor="yellow"> <td> ARRIVAL : </td> <td> DEPATURE : </td> </tr> <tr> <td> <input type="datetime-local" name="c1"> </td> <td> <input type="datetime-local" name="c2"> </td> </tr> <tr bgcolor="yellow"> <td>
  • 22. No.Of.Adults : </td> <td> No.Of.Childrens : </td> </tr> <tr> <td> <Select name="adults"> <option>1</option> <option>2</option> <option>3</option> <option>4</option> <option>5</option> </select> </td> <td> <Select name="children"> <option>0</option> <option>1</option> <option>2</option> <option>3</option> <option>4</option> <option>5</option>
  • 23. </select> </td> </tr> <tr> <td bgcolor="yellow"> No.Of.Rooms : </td> <td> <input type="text" name="room"> </td> </tr> <tr> <td bgcolor="yellow"> ROOM TYPE : </td> <td bgcolor="white"> <input type="radio" value="DELUX" name="type1"> DELUX <br> <input type="radio" value="A/C" name="type1"> A/C <br> <input type="radio" value="NON A/C" name="type1"> NON A/C
  • 24. </td> </tr> <tr> <td bgcolor="yellow"> Mode Of Payment </td> <td bgcolor="white"> <input type="radio" value= "CASH" name="pay"> CASH <input type="radio" value="CARD" name="pay"> CARD </td> </tr> <tr> <td bgcolor="yellow"> Maid ID: </td> <td> <input type="text" name="id"> </td> </tr> <tr> <td bgcolor="yellow"> Contact No :
  • 25. </td> <td> <input type="text" name="no"> </td> </tr> <tr><td colspan="2"> <center><input type="submit" value="BOOK MY ROOM"></center> </td> </tr> </table> </center> </body> </html> Php script .PHP <?php echo "<font color='RED'>"; echo"<center>BOOKING CONFIRMATION</center>"; echo "</font>"; echo "<br>"; echo "<br>"; echo "<font color='BLUE'>"; echo"From : ";
  • 26. $adate=date_create($_REQUEST["c1"]); echo date_format($adate,'d-m-Y'); echo"To:"; $ddate=date_create($_REQUEST["c2"]); echo date_format($ddate,'d-m-Y'); echo "<br>"; echo "<br>"; echo (" No of Rooms :".$_REQUEST["room"]); echo "<br>"; echo "<br>"; $adult=$_REQUEST["adults"]; $child=$_REQUEST["children"]; echo ($_REQUEST["type1"]." ROOM BOOKED FOR ".$adult." ADULT ".$child." CHILDREN"); echo "<br>"; echo "<br>"; echo ("YOUR PAYEMENT IS COMPLETED SUCCESSFULLY AND YOUR PAYMENT MODE IS ".$_REQUEST["pay"]); echo "<br>"; echo "<br>"; echo("THE CONFIRMATION SEND TO THE FOLLOWING MAIL ID : "); echo"<font color='RED'>"; echo($_REQUEST["id"]); echo "</font>"; echo "OR CONTACT NO : " ;
  • 27. echo"<font color='RED'>"; echo($_REQUEST["no"]); echo "</font>" ?> Output: Result: Thus the above hotel room booking user interface HTML design and producing the confirmation PHP script has been successfully designed and displays the output.
  • 28. Ex No : 6 CLIENT-SLIDE DATA VALIDATION Aim : To demonstrate form validation in PHP. Algorithm : Step 1 : Start. Step 2 : To create a web page with required controls to get user registration details Step 3 : Read user inputs using GET/POST in PHP program. Step 4: Perform data validation by using isempty() , filter_var() functions. Step 5: Display validation notification. Step 6 : Stop. Program: “formvalidation.php” <html> <head> <style> .error { color:#FF0000; } </style> </head> <body> <?php $nameerr=$emailerr=$gendererr=" ";
  • 29. $name=$email=$gender=$department=" "; if($_SERVER["REQUEST_METHOD"]=="POST") { if(empty($_POST["name"])) { $nameerr="Name is Required"; } else { $name=$_POST["name"]; } if(empty($_POST["email"])) { $emailerr="Email is Required"; } else { $email=$_POST["email"]; if(!filter_var($email,FILTER_VALIDATE_EMAIL)) { $emailerr="Invalid Email format"; } } if(empty($_POST["department"])) {
  • 30. $department=""; } else { $department=$_POST["department"]; } if(empty($_POST["gender"])) { $gendererr="Gender is Required"; } else { $gender=$_POST["gender"]; } } ?> <h2> Registration Form</h2> <p> <span class="error">*required field.</span></p> <form method="POST"> <table> <tr> <td>Name:</td> <td><input type="text" name="name"> <span class="error">*
  • 31. <?php echo $nameerr; ?> </span> </td> </tr> <tr> <td>Email:</td> <td ><input type="text" name="email"> <span class="error">* <?php echo $emailerr; ?> </span> </td> </tr> <tr> <td>Department:</td> <td><input type="text" name="department"> </td> </tr> <tr> <td>Gender:</td> <td> <input type="radio" name="gender" value="female">female
  • 32. <input type="radio" name="gender" value="male">male <span class="error">* <?php echo $gendererr; ?> </span> </td> </tr> <td><input type="submit" name="submit" value="submit"> </td> </table> </form> <?php echo "<h2> Your Given Details: </h2><br>"; echo $name,"<br>",$email,"<br>",$department,"<br>",$gender; ?> </body> </html> Output:
  • 33. Result: Thus the form validation is performed successfully in PHP.
  • 34. Exercise: 7 Date : Develop a PHP application for MYSQL database connection. Aim: To develop a student data retrieval page in PHP. Algorithm: Step 1 : Start the process Step 2: Create the MYSQL database. Step 3: Create the student table in MYSQL database. Step 4: Insert the values to the student table. Sept 5: Create the connection object using mysqli(). Sept 6: Retrieve the data from the table using SELECT query. Step 7: Display the output each in retrieved row in the Browser. Step 8: Close the MYSQL connection. Step 9: Stop the process
  • 35. .PHP <?php $conn=new mysqli("192.168.24.191","student","student","191ca003db"); if(!$conn){ die('COULD NOT CONNECTED;'.mysql_error()); } echo('CONNECTED SUCCESSFULLY'); ECHO"<BR>"; ECHO"<BR>"; $a="select*from mytable3"; $result=$conn->query($a); if($result->num_rows>0){ while($row=$result->fetch_assoc()){ echo"NAME:".$row["name"]."-ROLL NO:".$row["rno"]."<br>"; } }else { echo"0 results"; } mysqli_close($conn); ?>
  • 37. Result: Thus the above MYSQL database connection to the PHP application has been successfully designed and displays the output.
  • 38. Exercise: 8 Date : Develop a PHP script with Session and Cookie. Aim: To develop a College home page for display the visit count using session and cookie in PHP. Algorithm: Step 1 : Start the process Step 2: Design the college home page. Step 3: Set the cookies value using setcookie(). Step 4: Use the $_COOKIE variable for store the value. Step 5: Display the total number of visits. Step 6: Stop the process .PHP <html> <head> <title>PHP CODE TO COUNT NUMBER OF VISITORS USING COOKIES </title> </head> <h1><center>WELCOME TO DR.N.G.P ARTS AND SCIENCE COLLEGE</center></h1> <ul>COURSES <li>BCA</li> <li>BBA</li> <li>B.Sc(CS)</li> <li>B.Com</li>
  • 39. <li>B.Sc(IT)</li> </ul> <?php if(!isset($_COOKIE['count'])){ echo"WELCOME THIS IS THE FIRST TIME YOU VIEWED THIS PAGE"; $cookie=1; setcookie("count",$cookie); } else { $cookie=++$_COOKIE['count']; setcookie ("count",$cookie); echo "YOU HAVE VIEWED THIS PAGE ".$_COOKIE['count']."TIMES"; } ?> </BODY> </html> OUTPUT:
  • 40. Result: Thus the above college home page number of visit application using session and cookie value has been successfully designed and displays the output. Exercise: 9 Date : Develop a PHP application for send an Email.
  • 41. Aim: To develop a PHP application to send a leave email. Algorithm: Step 1 : Start the process. Step 2: Define the mail properties. Step 3: Set the cookies value using setcookie(). Step 4: Use the $_COOKIE variable for store the value. Step 5: Display the total number of visits. Step 6: Stop the process.
  • 42. .PHP <html> <head> <title>SENDING HTML EMAIL USING PHP</title> </head> <body> <?php $to="191ca003@drngpasc.ac.in"; $subject="LEAVE REQUEST"; $message=("<b>I AM REQUESTING LEAVE ON 10/05/2022"."<H1>AKASH P </h1>"); $header=("From:bca2022@gmail.comrn"."MINE-Version: 1.0rn"."Content-type: text/htmlrn"); $retval=mail ($to,$subject,$message,$header); if($retval == true) echo"MESSAGE SENT SUCCESSFULLY....."; else
  • 43. echo"MESSAGE COULD NOT SENT...."; ?> </BODY> </html>
  • 44. OUTPUT: Result: Thus the above leave email PHP script has been successfully designed and displays the output.
  • 45. Exercise: 10 Date : Create a PNG file with different shapes. Aim: To Create PHP web page to display the different shapes in a PNG. Algorithm: Step 1 : Start the process Step 2: Define image size using imagecreate(). Step 3: Set the color of the images using imagecolorallocate(). Step 4: Use the different image function for forming the shapes in the PNG. Step 5: Display the shapes with PNG in PHP. Step 6: Stop the process
  • 48. Result: Thus the above different shapes with PNG image in PNP has been successfully designed and displays the output.
  • 49. Exercise: 11 Aim: To display the concatenation of the first and second input of a user using Angular JS. Algorithm: Step 1 : Start the process Step 2: Create two label and two textbox for getting input from user. Step 3: Concatenated the two string Step 4: Display the output Step 5: Stop the process PROGRAM <html> <script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.6.9/angular.min.js"></script> <body> <div ng-app="myApp" ng-controller="myCtrl"> First Name: <input type="text" ng-model="firstName"><br> Last Name: <input type="text" ng-model="lastName"><br> <br> Full Name: {{firstName + " " + lastName}} </div> <script> var app = angular.module('myApp', []); app.controller('myCtrl', function($scope) { $scope.firstName = "John"; $scope.lastName = "Doe";