Abhishekkumar PHP

Download as pdf or txt
Download as pdf or txt
You are on page 1of 37

Practical file

Programming in PHP Laboratory

(UGCA-1930)

Submitted by: Abhishek Kumar

1922801

BCA 5

Submitted to: Ms. Manisha Sharma,

Mr. Manjit Singh


Practical-1
Ques: Take values from the user and compute sum, subtraction, multiplication,
division and exponent of value of the variables.

Output
Practical-2
Ques: Write a program to find area of the following shapes: circle, rectangle,
triangle, square, trapezoid and parallelogram.

Output
Practical-3
Ques: Compute and print roots of quadratic equation.
Output
Practical-4
Ques: Write a program to determine whether a triangle is isosceles or not?
Output
Practical-5
Ques: Write a program to sum of natural number given by the user from 1 to N.
Output
Practical-6
Ques: Write a program to print a multiplication table of the given input.
Output
Practical-7
Ques: Print Fibonacci Series up to n numbers e.g. 0 1 1 2 3 5 8 13 21……..n.
Output
Practical-8
Ques: Write a program to find factorial of any number.
Output
Practical-9
Ques: Determine prime numbers within a specific range.
Output
Practical-10
Ques: Write a program to compute , the Average and Grade of students marks.
Output
Practical-11
Ques: Compute addition, subtraction and multiplication of a matrix.
Output
Practical-12
Ques: Count total number of vowels in a word “Develop & Empower Individuals”.

Output
Practical-13
Ques: Determine whether a string is palindrome or not.

Output
Practical-14
Ques: Display word after sorting in alphabetical order.

Output
Practical-15
Ques: Check whether a number is given range using functions.
Output
Practical-16
Ques: Create a web page to accept a strings a string and calculates number of
upper case and lower case letters available in that string.

Output
Practical-17
Ques: Design a program to reverse a string word by word.

Output
Practical-18
Ques: Create a web page with login form. On submitting the form user should
navigate to the profile page.
Output
Practical-19
Ques: Design a front page of a college or department using graphics method.

<?php

$image= imagecreate(1500,1500);

$bg=imagecolorallocate($image,100,125,255);

//Background

$size=50; // change this value to increase the lines

$background_color = ImageColorAllocate ($image, 255, 255, 255);

for($i=1200;$i<=1500;$i +=$size){

$r=rand(1,255);

$g=rand(1,255);

$b=rand(1,255);

$text_color = ImageColorAllocate ($image, $r, $g,$b);

imageline ($image,$i,1200,$i,1500,$text_color);

// Horizontal lines

for($i=1200;$i<=1500;$i +=$size){

$r=rand(1,255);

$g=rand(1,255);

$b=rand(1,255);

$text_color = ImageColorAllocate ($image, $r, $g,$b);

imageline ($image,0,$i,1500,$i,$text_color);

//Top Line

$txtline=imagecolorallocate($image,0,0,0);

imageline ($image,10,30,1490,30,$txtline);

//Bottom Line
$txtline=imagecolorallocate($image,0,0,0);

imageline ($image,10,100,1490,100,$txtline);

//Left Line

$txtline=imagecolorallocate($image,0,0,0);

imageline ($image,10,30,10,100,$txtline);

//Right Line

$txtline=imagecolorallocate($image,0,0,0);

imageline ($image,1490,30,1490,100,$txtline);

$txtline=imagecolorallocate($image,0,0,0);

imageline ($image,10,120,1490,120,$txtline);

$txtline=imagecolorallocate($image,0,0,0);

imageline ($image,10,1190,1490,1190,$txtline);

$txtline=imagecolorallocate($image,0,0,0);

imageline ($image,10,120,10,1190,$txtline);

$txtline=imagecolorallocate($image,0,0,0);

imageline ($image,1490,120,1490,1190,$txtline);

$txt=imagecolorallocate($image,25,25,25);

$txt1=imagecolorallocate($image,255,0,0);

$txt2=imagecolorallocate($image,0,255,0);

$txt3=imagecolorallocate($image,255,0,0);

$text_color = ImageColorAllocate ($image, $r, $g,$b);

imageline ($image,0,$i,1500,$i,$text_color);

imagestring($image,25,20,50,"HOME",$txt1);

imagestring($image,25,70,50,"WHO WE ARE",$txt);

imagestring($image,25,170,50,"COURSES",$txt);

imagestring($image,25,250,50,"FACULTY",$txt);

imagestring($image,25,320,50,"STUDENT-ZONE",$txt);

imagestring($image,25,450,50,"NIRF",$txt);

imagestring($image,25,510,50,"ADMISSIONS 2022",$txt);
imagestring($image,25,1250,50,"SIGN UP",$txt2);

imagestring($image,25,1350,50,"SIGN IN",$txt3);

imagestring($image,200,700,150,"About Gian Jyoti",$txt);

imagestring($image,200,15,200,"Welcome to Gian Jyoti Institute of Management and

Technology. It is north India's premier destination in fields of management and computer ",$txt);

imagestring($image,200,15,220,"applications. Located in the heart of the bustling city of Mohali, this


institute of excellence has been setting milestones in academics and placements. ",$txt);

imagestring($image,200,15,240,"The unique teacher taught ambience here fosters innovation and


leadership. Students embark on a lifelong journey of self discovery and learning by initiative ",$txt);

imagestring($image,200,15,260,"in an atmosphere that is positively demanding and fiercely


competitive.",$txt);

header("Content-Type:image/png");

imagepng($image);

imagedestroy($image);

?>

Output
Practical-20
Ques: Design a web page to upload and download a files.

Uploading file

<html>

<body>

<h1>Uploading a file</h1>

<form action="upload.php" method="post" enctype="multipart/form-data">

<br><br>

Select image to upload:

<input type="file" name="fileToUpload" id="fileToUpload"><br><br>

<input type="submit" value="Upload Image" name="submit">

</form>

</body>

</html>

Upload.php

<?php

$target_dir = "E:\Upload";

$target_file = $target_dir . basename($_FILES["fileToUpload"]["name"]);

$uploadOk = 1;

$imageFileType = strtolower(pathinfo($target_file,PATHINFO_EXTENSION));

// Check if image file is a actual image or fake image

if(isset($_POST["submit"])) {

$check = getimagesize($_FILES["fileToUpload"]["tmp_name"]);

if($check !== false) {

echo "File is an image - " . $check["mime"] . ".";


$uploadOk = 1;

} else {

echo "File is not an image.";

$uploadOk = 0;

// Check if file already exists

if (file_exists($target_file)) {

echo "Sorry, file already exists.";

$uploadOk = 0;

// Check file size

if ($_FILES["fileToUpload"]["size"] > 500000) {

echo "Sorry, your file is too large.";

$uploadOk = 0;

// Allow certain file formats

if($imageFileType != "jpg" && $imageFileType != "png" && $imageFileType != "jpeg"

&& $imageFileType != "gif" ) {

echo "Sorry, only JPG, JPEG, PNG & GIF files are allowed.";

$uploadOk = 0;

// Check if $uploadOk is set to 0 by an error

if ($uploadOk == 0) {

echo "Sorry, your file was not uploaded.";

// if everything is ok, try to upload file

} else {

if (move_uploaded_file($_FILES["fileToUpload"]["tmp_name"], $target_file)) {
echo "The file ". htmlspecialchars( basename( $_FILES["fileToUpload"]["name"])). " has been
uploaded.";

} else {

echo "Sorry, there was an error uploading your file.";

?>

Output

You might also like