0% found this document useful (0 votes)
9 views

PHP File

No

Uploaded by

jyotishkumar236
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
9 views

PHP File

No

Uploaded by

jyotishkumar236
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 56

Program 1.

Take values from the user and compute Sum, Subtraction,


Multiplication, Division and Exponent of value of the variables.

( a ) Following the code of PHP to compute the value of Arithmetic operations.

<html>
<title>Code one user input</title>
<body><center><h1>Arithmatic operation using User input in php
<br>*****************************************</h1></center>
<form action="code_one.php" method="get">
<p>Enter 1st Number: <input type="number" name='a' value="<?php echo $a;
?>"></p>
<p>Enter 2nd Number: <input type="number" name='b' value="<?php echo $b;
?>"></p>
<button type="submit" name="submit">Submit</button>
</form>
<?php
if(isset($_GET['submit'])){
$a=$_GET['a'];
$b=$_GET['b'];
$c=$a+$b;
echo "Sum of $a and $b is ".$c;
$d=$a-$b;
echo "<br>Subtraction of $a and $b is ".$d;
$e=$a*$b;
echo "<br>Multiplication of $a and $b is ".$e;
$f=$a/$b;
echo "<br>Division of $a and $b is ".$f;
$g=$a%$b;
echo "<br>Modulas of $a and $b is ".$g;
$h=$a**2;
echo "<br>$a Power 2 is ".$h;
} ?>
</body> </html>
Program 1. Take values from the user and compute Sum, Subtraction,
Multiplication, Division and Exponent of value of the variables.

OUTPUT PROGRAM 1

Fig.1.0 ( Compute the value of Arithmetic operations)

End of program one

**********
Program 2. Write a program to find area of following shapes: circle,
rectangle, triangle, square, trapezoid and parallelogram.

( a ) Following the code of PHP to find area of circle, rectangle, triangle, square,
trapezoid and parallelogram.

<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Area of shapes</title>
</head>
<body>
<center>
<h1>AREA OF SHAPES IN PHP <br>*********************************</h1>
</center>
<?php
$r=5;
$pi=3.14;
$a=$pi*$r*$r;
echo " code (a) AREA OF CIRCLE is = ", $a;
?>
<br/>
<?php
$length = 14;
$width = 12;
echo " code (b) AREA OF RECTANGLE IS = $length * $width = " . ($length * $width);
?>
<br/>
<?php
$base = 10;
$height = 15;
echo"code (c) AREA OF TRIANGLE";
echo "area with base $base and height $height = " . ($base * $height) / 2;
?>
<br/>
<?php
$s=13;
$area_square = $s*$s;
echo "code (d) AREA OF SQUARE =";
echo $area_square;
?>
<br/>
<?php
$h1=0;
$b1=32; $b2=12;
$a1 = ($b1+ $b2)/2*$h1;
echo sprintf("code (e) AREA OF TRAPEZOID : %f ",$a1);
?>
<br/>
<?php
$base1=4;
$height2=18;
$area_parallelogram=$base1*$height2;
echo " code (f) Area of the parallelogram=";
echo $area_parallelogram;
?>
<br/>
</body>
</html>
Program 2. Write a program to find area of following shapes: circle, rectangle,
triangle, square, trapezoid and parallelogram.

OUTPUT PROGRAM 2

Fig.2.0 ( Find the area of shapes)

End of program two

**********
Program 3. Compute and print roots of quadratic equation.

( a ) Following the code of PHP to Compute and print roots of quadratic


equations.

<html>
<head>
<title> PHP Program To find the roots of Quadratic Equation</title>
</head>
<body>
<center>
<h1>PHP Program To find the roots of Quadratic Equation
<br>*****************************************************</h1>
<form method="post">
<table border="0">
<tr>
<td> <input type="text" name="num1" value="" placeholder="Enter 1st value"/> </td>
</tr>
<tr>
<td> <input type="text" name="num2" value="" placeholder="Enter 2nd value"/> </td>
</tr>
<tr>
<td> <input type="text" name="num3" value="" placeholder="Enter 3rd value"/> </td>
</tr>
<tr>
<td> <input type="submit" name="submit" value="Submit"/>
</td>
</tr>
</table>
</form>
<?php
if(isset($_POST['submit']))
{
$a = $_POST['num1'];
$b = $_POST['num2'];
$c = $_POST['num3'];
$precision = 4;
$d = $b * $b - 4 * $a * $c; // Discriminant of a quadratic equation
if($d < 0)
{
echo " Roots are complex numbers. " ;
echo " Roots of quadratic equation are: " ;
echo -$b/(2*$a). " + " .number_format(sqrt(-$d)/(2*$a), $precision)."i ";
echo ", ". -$b/(2*$a).number_format(-sqrt(-$d)/(2*$a), $precision)."i" ;
}
else if($d == 0)
{
echo "Both roots are equal.";
$root1 = -$b /(2* $a);
echo"Root of quadratic equation is: " .$root1 ;
return 0;
}
else
{
echo "Roots are real numbers.";
$root1 = ( -$b + sqrt($d)) / (2* $a );
$root2 = ( -$b - sqrt($d)) / (2* $a);
echo "Roots of quadratic equation are: " .$root1 .$root2 ;
}
return 0;
}
?>
</center>
</body>
</html>
Program 3. Compute and print roots of quadratic equation.

OUTPUT PROGRAM 3

Fig.3.0 ( Compute and print roots of quadratic equations.)

End of program three

**********
Program 4. Write a program to determine whether a triangle is
isosceles or not?

( a ) Following the code of PHP to determine whether a triangle is isosceles or


not.

<html>
<head>
<title>PHP Program To read three sides of a triangle and print the type of the
triangle</title>
</head>
<body>
<center>
<h1>Program to determine a triangle is isosceles or
not.<br>********************************************</h1>
<form method="post">
<table border="0">
<tr>
<td> <input type="text" name="num1" value="" placeholder="Enter length of 1st
side"/>
</td>
</tr>
<tr>
<td> <input type="text" name="num2" value="" placeholder="Enter length of 2nd
side"/>
</td>
</tr>
<tr>
<td> <input type="text" name="num3" value="" placeholder="Enter length of 3rd
side"/>
</td>
</tr>
<tr>
<td> <input type="submit" name="submit" value="Submit"/>
</td>
</tr>
</table>
</form>
<?php
if(isset($_POST['submit']))
{
$a = $_POST['num1'];
$b = $_POST['num2'];
$c = $_POST['num3'];
echo "Given sides : ".$a." ".$b." ".$c. "</br>";
if(($a*$a)+($b*$b)==($c*$c) || ($b*$b)+($c*$c)==($a*$a) || ($c*$c)+($a*$a)==($b*$b)){
echo("Right angle triangle");}
else
if(($a==$b) && ($b==$c))
{
echo("Equilateral triangle");
}
else
if(($a==$b) || ($b==$c) || ($c==$a))
{
echo("Isosceles triangle");
}
else
if(($a!=$b && $b!=$c && $c!=$a))
{
echo("Scalene triangle");
}
return 0;
}
?>
</center>
</body>
</html>
Program 4. Write a program to determine whether a triangle is isosceles or not?

OUTPUT PROGRAM 4

Fig.4.0 ( Program to determine whether a triangle is isosceles or not.)

End of program four

**********
Program 5. Print multiplication table of a number input by the user.

( a ) Following the code of php to print multiplication table of a number through

User input.

<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Multiplication table of a number input by the user</title>
</head>
<body><center>
<h1>Multiplication table of a number input by the use
<br>*******************************************</h1>
<form Method="post"><br><br>
Enter number:<input type="text" name="value"/><br><br>
<input type="submit" name="btn" value="print table" />
</form>
<?php
if(isset($_POST['btn'])){
$n=$_POST['value'];
$res=0;
for($i=1;$i<=10;$i++){
$res=$n*$i;
echo $n;
echo"*";
echo $i;
echo "=";
echo $res;
echo "<br>";}}
?>
</center> </body>
</html>
Program 5. Print multiplication table of a number input by the user.

OUTPUT PROGRAM 5

Fig.5.0 ( Multiplication table of a number through user input.)

End of program five

**********
Program 6. Calculate sum of natural numbers from one to n number.

( a ) Following the code of php to. calculate the sum of natural numbers from
one to n number.

<html>
<head>
<title>PHP Program To find the Sum of N natural numbers</title>
</head>
<body>
<center>
<h1>PHP Program To find the Sum of N natural numbers
<br>*********************************</h1>
<form method="post">
<table border="0"><tr>
<td> <input type="text" name ="num" value="" placeholder="Enter a positive
integer"/> </td></tr><tr>
<td> <input type="submit" name ="submit" value="Submit"/> </td></tr>
</table>
</form>
<?php
if(isset($_POST['submit'])){
$n = $_POST['num'];
$sum = 0;
//Using loop to do sum of N natural numbers
for($i = 1; $i <= $n; ++$i){
$sum = $sum + $i;}
echo "Sum of $n natural numbers = $sum";
return 0;
}
?>
</center>
</body>
</html>
Program 6. Calculate sum of natural numbers from one to n number.

OUTPUT PROGRAM 6

Fig.6.0 ( Sum of natural numbers from one to n number.)

End of program Six

**********
Program 7. Print Fibonacci series up to n numbers e.g. 0 1 1 2 3 5 8
13 21…..n.

( a ) Following the code of php to print Fibonacci series up to n numbers

<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Fibonacci Series Program in PHP using For Loop</title>
</head>
<body>
<center>
<H1>Fibonacci Series Program for n number's
<br>*****************************************</H1>
<?php
$f1 = 0;
$f2 = 1;
$n = 30;
echo $f1;
echo '<br/>';
echo $f2;
for($i = 1; $i <= $n; $i++) {
$f3 = $f1 + $f2;
$f1 = $f2;
$f2 = $f3;
echo $f3 ."<br />";
}
?>
</center>
</body>
</html>
Program 7. Print Fibonacci series up to n numbers e.g. 0 1 1 2 3 5 8 13 21…..n.

OUTPUT PROGRAM 7

Fig.7.0 ( Fibonacci series up to n numbers.)

End of program Seven

**********
Program 8. Write a program to find the factorial of any number.

( a ) Following the code of php to find the factorial of any number.

<html>
<head>
<title> Factorial Program</title>
</head>
<body>
<center>
<h1> Factorial Program <br>**************************</h1>
<form method="POST">
<label>Enter a number</label>
<input type="text" name="number" />
<input type="submit" name="submit" value="Submit" />
</form>
<?php
if ($_POST['submit'] == "Submit") {
$input = $_POST['number'];
$fact = 1;
//iterating using for loop
for ($i = $input; $i >= 1; $i--) {
$fact = $fact * $i;
}
// Print output of the program
echo '<br>' . 'The factorial of the number ' . $input . ' is ' . $fact;
}
?>
</center>
</body>
</html>
Program 8. Write a program to find the factorial of any number.

OUTPUT PROGRAM 8

Fig.8.0 ( Program to find the factorial of any number.)

End of program Eight

**********
Program 9. Determine prime numbers within a specific range.

( a ) Following the code of php to Determine prime numbers within a specific


range

<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>To check if the number is prime or not</title>
</head>
<body>
<center>
<h1>Check if the number is prime or not <br>
**********************************</h1>
<form method="post">
Enter a Number: <input type="text" name="input"><br><br>
<input type="submit" name="submit" value="Submit">
</form>
<?php
if($_POST){
$input=$_POST['input'];
for ($i = 2; $i <= $input-1; $i++) {
if ($input % $i == 0) {
$value= True;}}
if (isset($value) && $value) {
echo '<br>'.'The Number '. $input . ' is not prime';
} else {
echo '<br>'.'The Number '. $input . ' is prime';}
}?>
</center>
</body>
</html>
Program 9. Determine prime numbers within a specific range.

OUTPUT PROGRAM 9

Fig.9.0 ( Determine prime numbers within a specific range.)

End of program Nine

**********
Program 10. Write a program to compute, the Average and Grade of
students marks.

( a ) Following the code of php to compute, the Average and Grade of students
marks

<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Student Grades</title>
</head>
<body>
<center>
<h1>Program to declare the result of
student<br>****************************************</h1>
<form method="post">
<table border="0">
<tr>
<td> <input type="text" name="marks1" value="" placeholder="Enter marks of subject
1"/>
</td>
<tr>
<td> <input type="text" name="marks2" value="" placeholder="Enter marks of subject
2"/>
</td>
<tr>
<td> <input type="text" name="marks3" value="" placeholder="Enter marks of subject
3"/>
</td>
</tr>
<tr>
<td> <input type="text" name="marks4" value="" placeholder="Enter marks of subject
4"/>
</td>
</tr>
<tr>
<td> <input type="text" name="marks5" value="" placeholder="Enter marks of subject
5"/>
</td>
</tr>
<tr>
<td> <input type="submit" name="submit" value="Submit"/>
</td>
</tr>
</table>
</form>
<?php

if(isset($_POST['submit'])){
$sub_1 = $_POST['marks1'];
$sub_2 = $_POST['marks2'];
$sub_3 = $_POST['marks3'];
$sub_4 = $_POST['marks4'];
$sub_5 = $_POST['marks5'];
}
$total = NULL;
$average = NULL;
$percentage = NULL;
$grade = NULL;
// calculation
$total = $sub_1 + $sub_2 + $sub_3 + $sub_4 + $sub_5;
$average = $total / 5.0;
$percentage = ($total / 500) * 100;
if ($average >= 90)
$grade = "O";
else if ($average >= 80 && $average < 90)
$grade = "A+";
else if ($average >= 70 && $average < 80)
$grade = "B+";
else if ($average >= 60 && $average < 70)
$grade = "B";
else
$grade = "C";
// to print output
echo '<br>'."The Total marks = " . $total . "/500\n";
echo '<br>'."The Average marks = " . $average . "\n";
echo '<br>'."The Percentage = " . $percentage . "%\n";
echo '<br>'."The Grade = '" . $grade . "'\n";
?>
</center>
</body>
</html>
Program 10. Write a program to compute, the Average and Grade of students
marks.

OUTPUT PROGRAM 10

Fig.10.0 ( to compute, the Average and Grade of students marks.)

End of program Ten

**********
Program 11. Compute addition, subtraction and multiplication of a
matrix.

( a ) Following the code of php to compute, the addition, subtraction and


multiplication of a matrix.

<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Compute addition, subtraction and multiplication of a matrix</title>
</head>
<body>
<center>
<h1>Compute addition, subtraction and multiplication of a
matrix<br>*********************************</h1>
<?php
$a = array(array(1,2,3),array(4,5,6),array(7,8,9));
$b = array(array(7,8,9),array(4,5,6),array(1,2,3));
$m=count($a);
$n=count($a[2]);
$p=count($b);
$q=count($b[2]);
echo "the first matrix :"."<br/>";
for ($row = 0; $row < $m; $row++) {
for ($col = 0; $col < $n; $col++)
echo " ".$a[$row][$col];
echo "<br/>";
}
echo "the second matrix :"."<br/>";
for ($row = 0; $row < $p; $row++) {
for ($col = 0; $col < $q; $col++)
echo " ".$b[$row][$col];
echo "<br/>";
}
echo "the transpose for the first matrix is:"."<br/>";
for ($row = 0; $row < $m; $row++) {
for ($col = 0; $col < $n; $col++)
echo " ".$a[$col][$row];
echo "<br/>";
}
echo "the addition of matrices is:"."<br/>";
for ($row = 0; $row < 3; $row++) {
for ($col = 0; $col < 3; $col++)
echo " ".$a[$row][$col]+$b[$row][$col]." ";
echo "<br/>";
}
echo " The multiplication of matrices: <br/>";
$result=array();
for ($i=0; $i < $m; $i++) {
for($j=0; $j < $q; $j++){
$result[$i][$j] = 0;
for($k=0; $k < $n; $k++)
$result[$i][$j] += $a[$i][$k] * $b[$k][$j];
}
}
for ($row = 0; $row < $m; $row++) {
for ($col = 0; $col < $q; $col++){
echo " ".$result[$row][$col];
}
echo "<br/>";
}
?>
</center>
</body>
</html>
Program 11. Compute addition, subtraction and multiplication of a matrix.

OUTPUT PROGRAM 11

Fig.11.0 ( Compute addition, subtraction and multiplication of a matrix..)

End of program Eleven

**********
Program 12. Count total number of vowels in a word “Develop &
Empower Individuals”.

( a ) Following the code of php to count the total number of vowels in a word
“Develop & Empower Individuals”.

<!DOCTYPE html>
<html>
<body>
<center >
<h3>Total number of vowels in a word “Develop & Empower
Individuals”<br>**************************************************</h3>
<?php
$vCount = 0;
$str = "Develop and Empower Individuals";
$str = strtolower($str);

for($i = 0; $i < strlen($str); $i++) {


if( $str[$i] == 'a' || $str[$i] == 'e' || $str[$i] == 'i' || $str[$i] == 'o' || $str[$i] == 'u') {
$vCount++;
}
}
echo "Number of vowels : " , $vCount;
echo "<br>";
?>
</center>
</body>
</html>
Program 12. Count total number of vowels in a word “Develop & Empower
Individuals”.

OUTPUT PROGRAM 12

Fig.12.0 ( Total number of vowels in a word “Develop & Empower Individuals”

End of program Twelve

**********
Program 13. Determine whether a string is palindrome or not?

( a ) Following the code of php to check a string is palindrome or not.

<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>String is Palidrome or not</title>
</head>
<body>
<center>
<h1>Palidrome String <br>**********************************</h1>
<form action="#" method="post">
<label for="#">Enter a string</label>
<input type="text" name="str" size="70"><br><br>
<input type="submit" name=" " value="Check">
</form>

<?php
$sub=isset($_POST['str']);
if($sub){
$rev=strrev($_POST['str']);
if($rev==$_POST['str']){
echo $_POST['str']." String is palidrome";
}
else
echo $_POST['str']." String is not palidrome";
}
?>
</center>
</body>
</html>
Program 13. Determine whether a string is palindrome or not?

OUTPUT PROGRAM 13

Fig.13.0 ( Output a string is palindrome or not )

End of program Thirteen

**********
Program 14. Display word after Sorting in alphabetical order.

( a ) Following the code of php to display word after Sorting in alphabetical


order.

<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Alphabet orders</title>
</head>
<body>
<center>
<h1>Sorting in alphabetical order. <br>***********************************</h1>
<h3>
<?php
$word = " DCABFEGH ";
$word = str_split($word);
sort($word);
$word = implode($word);
echo "DCABFEGH is sorted to <br><br><br>";
echo $word;
?>
</h3>
</center>
</body>
</html>
Program 14. Display word after Sorting in alphabetical order.

OUTPUT PROGRAM 14

Fig.14.0 ( Output to display word after Sorting in alphabetical order.)

End of program Fourteen

**********
Program 15. Check whether a number is in a given range using
functions.

( a ) Following the code of php to check whether a number is in a given range


using functions.

<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>number is in a given range using functions.</title>
</head>
<body>
<center>
<h1>Check if number is in a given range using functions
<br>*************************************</h1>
<h3>Given range is = 10 to 100 </h3><h4>
<form action="<?php echo $_SERVER['PHP_SELF']; ?>" method="post">
<label for="#">Enter input</label>
<input type="text" name="int">
<input type="submit" value="Submit">
</form>
<?php
$int = $_POST['int'];
$min = 10;
$max = 100;
if ($int > $min && $int < $max) {
echo "$int is in range";} else {
echo "$int is not range";}
?>
</center> </h4>
</body>
</html>
Program 15. Check whether a number is in a given range using functions.

OUTPUT PROGRAM 15

Fig.15.0 ( Output of a given number )

End of program Fifteen

**********
Program 16. Write a program accepts a string and calculates number
of upper case letters and lower case letters available in that string.

( a ) Following the code to calculates number of upper case letters and lower
case letters available in a string

<!DOCTYPE html>

<head>

<title>Calculat upper aand lower</title>


</head>
<body>
<center>
<h1>Calculates number of upper case letters and lower case letters available in that
string. <br>*************************************</h1><h2>
<form action="<?php echo $_SERVER['PHP_SELF']; ?>" method="post">
<label for="#">Enter string</label>
<input type="text" name="str">
<input type="submit" value="Submit">
</form><br><?php
$str = $_POST['str'];
$upper = 0;
$lower = 0;
foreach (str_split($str) as $i) {
if (ctype_upper($i)) {
$upper++;
} else if (ctype_lower($i)) {
$lower++;}}
echo "String: $str <br><br>";
echo "Upper case letters: $upper <br><br>";
echo "Lower case letters: $lower";
?> </h2>
</center>
</body></html>
Program 16. Write a program accepts a string and calculates number of upper
case letters and lower case letters available in that string.

OUTPUT PROGRAM 16

Fig.16.0 ( Output number of upper case letters and lower case letters)

End of program Sixteen

**********
Program 17. Design a program to reverse a string word by word.

( a ) Following the code a program to reverse a string word by word.

<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Reverse a string word by word.</title>
</head>
<body>
<center>
<h1>A program to reverse a string word by word.
<br>*************************************</h1>
<h2>
<form action="<?php echo $_SERVER['PHP_SELF']; ?>" method="post">
<label for="#">Enter input</label>
<input type="text" name="str">
<input type="submit" value="Submit">
</form> <br>
<?php
$str = $_POST['str'];
$arr = explode(" ", $str);
$arr = array_reverse($arr);
$str = implode(" ", $arr);
echo $str;
?>
</h2>
</center>
</body>
</html>
Program 17. Design a program to reverse a string word by word.

OUTPUT PROGRAM 17

Fig.17.0 ( Reverse a string word by word)

End of program Seventeen

**********
Program 18. Write a program to create a login form. On submitting
the form, the user should navigate to profile page.

( a ) Following the code to create a login form

<!DOCTYPE html>
<head>
<title>login form in php</title>
</head>
<body>
<center>
<h1>A program of a login form.<br>*************************************</h1>
<h2>
<form action="<?php echo $_SERVER['PHP_SELF']; ?>" method="post">
<label for="username">Username:</label>
<input type="text" name="username" id="username">
<br>
<label for="password">Password:</label>
<input type="password" name="password" id="password">
<br>
<input type="submit" value="Login">
</form>
<?php
if (isset($_POST['username']) && isset($_POST['password'])) {
$username = $_POST['username'];
$password = $_POST['password'];
if ($username == 'jaspreet' && $password == 'admin') {
echo "<br>Welcome to profile page $username";
} else {
echo "<br>Invalid username or password";}}
?>
</h2>
</center>
</body> </html>
Program 18. Write a program to create a login form. On submitting the form,
the user should navigate to profile page.

OUTPUT PROGRAM 18

Fig.18.0 (Login form)

End of program Eighteen

**********
Program 19. Design front page of a college or department using
graphics method.

( a ) Following code front page of a college or department using graphics


method.

<!DOCTYPE html>
<html>
<head>
<title>Home</title>
<link rel="stylesheet" href="styles.css">
</head>
<style>
/********** CSS **********/
*{
margin:0px;
padding:0px;
}
html, body {
font-family: 'Times New Roman', Times, serif;
font-size: 14px;
color: #242424;
}
.container {
width: 1200px;
margin:0px auto;
}
.main-section {
width: 100%;
float: left;
padding:50px 0px 40px 0px;
}
.heading {
font-size: 22px;
font-weight: 500;
border-bottom: 1px solid #ff5722;
margin-bottom:25px;
color: #ff5722;
}
/********** CSS Ends **********/
/********** Logo CSS Starts **********/
.logo {
width:25%;
}
/********** Logo CSS Ends **********/

/********** Main Menu CSS Starts **********/


nav {
width: 100%;
float: left;
background: #ff5722;
padding:15px 0px;
}
nav a {
color: #fff;
text-decoration: none;
font-size: 17px;
border-right: 1px solid #ffc3c3;
padding:2px 20px;
}
/********** Main Menu CSS Ends **********/

/********** Slider CSS Starts **********/


.slider img {
width:100%;
}
/********** Slider CSS Ends **********/
/********** News, Event, Notice Board CSS Starts **********/
.event {
width: 31%;
margin-right: 1%;
float: left;
}
.event div {
padding:10px;
background-color: #f0f3fa;
}
.event ul li {
margin-bottom: 20px;
width: 100%;
float: left;
}
/********** News, Event, Notice Board CSS Ends **********/
/********** About Us CSS Starts **********/
.about-us img {
width:24%;
float:left;
}
.about-us div {
width:70%;
margin-left:20px;
float:left;
line-height:35px;
}
/********** About Us CSS Ends **********/
/********** Placement CSS Starts **********/
.placement img {
border:1px solid #dfdfdf;
}
/********** Placement CSS Ends **********/
/********** Footer CSS Starts **********/
.footer {
background-color:#1f2836;
padding:70px 0px;
width:100%;
float:left;
}
.footer-sect {
width:33%;
float:left;
}
.footer-sect h2 {
color:#fff;
margin-bottom: 20px;
}
.footer-sect p {
color: #fff;
line-height: 22px;
padding:0px 30px 20px 0px;
}
.footer-menu li {
width: 50%;
float: left;
margin-bottom: 10px;
}
.footer-menu li a {
color:#fff;
text-decoration: none;
}
.footer-contact li {
margin-bottom:15px;
list-style: none;
color: #fff;
}
/********** Footer CSS Ends **********/
</style>
<body>
<!---------- Meta HTML Ends --------->
<!---------- Logo HTML Starts --------->
<div class="container">
<img src="img/logo.png" class="logo">
</div>
<!---------- Logo HTML Ends --------->
<!---------- Main Menu HTML Starts --------->
<nav>
<div class="container">
<a href="#">Home</a>
<a href="#">About us</a>
<a href="#">Admission</a>
<a href="#">Gallery</a>
<a href="#">Notice Board</a>
<a href="#">Events</a>
<a href="#">Tutorial</a>
<a href="#">Contact us</a>
</div>
</nav>
<!---------- Main Menu HTML Ends --------->
<!---------- Slider HTML Starts --------->
<div class="slider">
<img src="img/GImgHome-banner-alumni ok_ZMCCX0.jpg">
</div>
<!---------- Slider HTML Ends --------->
<!---------- News, Event, Notice Board HTML Starts --------->
<div class="container">
<div class="main-section">
<!---------- News Section --------->
<div class="event">
<h2 class="heading">Campus News</h2>
<div>
<marquee direction="up" scrollamount="7" style="height:400px;">
<ul>
<li><img src="img/news.jpeg"> Desktop publishing software like Aldus PageMaker
including versions Lorem Ipsum</li>
<li><img src="img/event.jpg"> Lorem Ipsum is simply dummy text of the printing and
typesetting industry.</li>
<li><img src="img/news.jpeg"> Desktop publishing software like Aldus PageMaker
including versions Lorem Ipsum</li>
<li><img src="img/event.jpg"> Lorem Ipsum is simply dummy text of the printing and
typesetting industry.</li>
<li><img src="img/news.jpeg"> Desktop publishing software like Aldus PageMaker
including versions Lorem Ipsum</li>
</ul>
</marquee>
</div>
</div>
<!---------- Event Section --------->
<div class="event">
<h2 class="heading">Events</h2>
<div>
<marquee direction="up" scrollamount="7" style="height:400px;">
<ul>
<li><img src="img/event.jpg"> Lorem Ipsum is simply dummy text of the printing and
typesetting industry.</li>
<li><img src="img/event.jpg"> Lorem Ipsum is simply dummy text of the printing and
typesetting industry.</li>
<li><img src="img/news.jpeg"> Desktop publishing software like Aldus PageMaker
including versions Lorem Ipsum</li>
<li><img src="img/event.jpg"> Lorem Ipsum is simply dummy text of the printing and
typesetting industry.</li>
<li><img src="img/news.jpeg"> Desktop publishing software like Aldus PageMaker
including versions Lorem Ipsum</li>
</ul>
</marquee>
</div>
</div>
<!---------- Notice Board Section --------->
<div class="event">
<h2 class="heading">Notice Boards</h2>
<div>
<marquee direction="up" scrollamount="7" style="height:400px;">
<ul>
<li><img src="img/news.jpeg"> Desktop publishing software like Aldus PageMaker
including versions Lorem Ipsum</li>
<li><img src="img/event.jpg"> Lorem Ipsum is simply dummy text of the printing and
typesetting industry.</li>
<li><img src="img/news.jpeg"> Desktop publishing software like Aldus PageMaker
including versions Lorem Ipsum</li>
<li><img src="img/event.jpg"> Lorem Ipsum is simply dummy text of the printing and
typesetting industry.</li>
<li><img src="img/news.jpeg"> Desktop publishing software like Aldus PageMaker
including versions Lorem Ipsum</li>
</ul>
</marquee>
</div>
</div>
</div>
<!---------- News, Event, Notice Board HTML Ends --------->
<!---------- About Us HTML Starts --------->
<div class="main-section about-us">
<img src="img/about.jpg" >
<div>
<h2 class="heading">About Our College</h2>
<p> Ramgarhia Group of Institutes (Ramgarhia Institute of Engineering and Technology,
Ramgarhia Institute of Management & Advance Studies, Ramgarhia Institute of Health
Science & Research and Ramgarhia Institute of Nanny Care) have the vision for creating a
truly world class institutes which will cater to the needs of Indian and Overseas Industry,
Research and Educational Institutions. Ramgarhia Group of Institutes have tremendously
grown since their inception in 2003 and are well known for imparting the Quality Education
in the region.</p>
<img src="images/sign.png">
</div>
</div>
<!---------- About Us HTML Ends --------->
<!---------- Placement HTML Starts --------->
<div class="main-section">
<h2 class="heading">Placement</h2>
<marquee class="placement" direction="left" scrollamount="10">
<img src="img/company-6.jpg">
<img src="img/company-2.jpg">
<img src="img/company-4.jpg">
<img src="img/company-7.jpg">
<img src="img/company-14.jpg">
</marquee>
</div>
</div>
<!---------- Placement HTML Ends --------->
<!---------- Footer HTML Starts --------->
<div class="footer">
<div class="container">
<div class="footer-sect">
<h2>Best Institute For Education</h2>
<p>Contrary to popular belief, Lorem Ipsum is not simply random text. It has roots in a piece
of classical Latin literature from 45 BC, making it over 2000 years old. Richard
McClintock.</p>
<img src="images/icon-fb.png">
<img src="images/icon-tw.png">
<img src="images/icon-in.png">
<img src="images/icon-li.png">
</div>
<div class="footer-sect">
<h2>Quick Links</h2>
<ul class="footer-menu">
<li><a href="#"> > Home</a></li>
<li><a href="#"> > About us</a></li>
<li><a href="#"> > Tutorial</a></li>
<li><a href="#"> > Event</a></li>
<li><a href="#"> > Gallery</a></li>
<li><a href="#"> > Press Release</a></li>
<li><a href="#"> > Courses</a></li>
<li><a href="#"> > Contact Us</a></li>
</ul>
</div>
<div class="footer-sect">
<h2>Contact Info</h2>
<ul class="footer-contact">
<li><b>Email :</b> http://www.riet.ac.in/ </li>
<li><b>Call :</b> +91 -123 456 7890 </li>
<li><b>Fax :</b> +91 -123 4567890 </li>
</ul>
</div>
</div>
</div>
</body>
</html>
<!---------- Footer HTML Ends --------->
Program 19. Design front page of a college or department using graphics
method.

Fig.19.0 ( College homepage)

Fig.19.1 ( College about section )


OUTPUT PROGRAM 19.3

Fig.19.3 ( College placements & Footer section)

End of program Nineteen

**********
Program 20. Write a program to upload and download files.

( a ) Following a program to upload and download files.

<?php
if (isset($_POST["submit"])) {
if (isset($_FILES["image"])) {
$targetDir = "uploads";
$targetFile = $targetDir . basename($_FILES["image"]["name"]);
$uploadOk = 1;
$imageFileType = strtolower(pathinfo($targetFile, PATHINFO_EXTENSION));
$check = getimagesize($_FILES["image"]["tmp_name"]);
if ($check !== false) {
echo "File is an image - " . $check["mime"] . ".";
$uploadOk = 1;
} else {
echo "File is not an image.";
$uploadOk = 0;}
}
if (file_exists($targetFile)) {
echo "Sorry, file already exists.";
$uploadOk = 0;
}
if ($_FILES["image"]["size"] > 500000) {
echo "Sorry, your file is too large.";
$uploadOk = 0;
}
if (
$imageFileType != "jpg" && $imageFileType != "png" && $imageFileType != "jpeg"
&& $imageFileType != "gif"
){
echo "Sorry, only JPG, JPEG, PNG & GIF files are allowed.";
$uploadOk = 0;}
if ($uploadOk == 0) {
echo "Sorry, your file was not uploaded.";
} else {
if (move_uploaded_file($_FILES["image"]["tmp_name"], $targetFile)) {
echo "The file " . htmlspecialchars(basename($_FILES["image"]["name"])) . " has been
uploaded.";
} else {
echo "Sorry, there was an error uploading your file.";}}}
?>
<!DOCTYPE html>
<html>
<head>
<title>Upload and display image in PHP</title>
<link href="style.css" rel="stylesheet" type="text/css" />
<link href="form.css" rel="stylesheet" type="text/css" />
</head>
<body>
<div class="phppot-container">
<h1>Upload an Image <br>**********************</h1>
<form action="" method="post" enctype="multipart/form-data">
<div class="row">
<input type="file" name="image" required>
<input type="submit" name="submit" value="Upload">
</div>
</form>
<h1>Display uploaded Image:</h1>
<?php if (isset($_FILES["image"]) && $uploadOk == 1) : ?>
<img src="<?php echo $targetFile; ?>" alt="Uploaded Image">
<?php endif; ?>
<p> Download the image:
<a href="<?php echo $target_file; ?>">Download</a>
</p>
</div>
</body>
</html>
Program 20. Write a program to upload and download files.

OUTPUT PROGRAM 20

Fig.20 ( Upload & download files)

End of program Twenty

**********

You might also like