0% found this document useful (0 votes)
149 views60 pages

DWPD (3350702) Practical List

The document contains the code and output for 6 experiments (1A to 1F) on basic HTML elements and tags. Experiment 1A demonstrates displaying an image and hyperlinking using <img> and <a> tags. Experiment 1B adds a YouTube video using <iframe>. Experiment 1C creates a registration form using various form input tags like <label>, <input>, <textarea>. Experiment 1D designs a menu system using <ul> and <li> list tags. Experiment 1E creates a static page layout using <div> tags. Experiment 1F designs the Google homepage using CSS styling.

Uploaded by

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

DWPD (3350702) Practical List

The document contains the code and output for 6 experiments (1A to 1F) on basic HTML elements and tags. Experiment 1A demonstrates displaying an image and hyperlinking using <img> and <a> tags. Experiment 1B adds a YouTube video using <iframe>. Experiment 1C creates a registration form using various form input tags like <label>, <input>, <textarea>. Experiment 1D designs a menu system using <ul> and <li> list tags. Experiment 1E creates a static page layout using <div> tags. Experiment 1F designs the Google homepage using CSS styling.

Uploaded by

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

2

Experiment:-1A
Aim:-Write HTML codes for displaying image and demonstrate hyper linking.
Code:
<!DOCTYPE html>
<html lang="en">
<head>
<title>Prac 1A</title>
</head>
<body>
<img src="Logo.png" alt="logo" width="500" height="300"><br>
<h1>Visit: <a href="https://www.youtube.com/" target="_blank">Youtube</a></h1>
</body>
</html>
Output:

DWPD(3350702) 196470307045
2

Experiment:-1B
Aim:- Write HTML codes to attach video on webpage using embed tag in html.
Code:
<html>
<head>
<title>Prac 1B</title>
</head>
<body>
<h4>Following video add using Embed tag</h4>
<iframe width="560" height="315" src="https://www.youtube.com/embed/oZ8YhAPfJDA"
title="YouTube video player" frameborder="0" allow="accelerometer; autoplay; clipboard-
write; encrypted-media; gyroscope; picture-in-picture" allowfullscreen></iframe>
</body>
</html>
Output:

DWPD(3350702) 196470307045
2

Experiment:-1C
Aim:- Write a code for design registration form using HTML tag.
Code:
<html>
<head>
<title>Prac 1C</title>
</head>
<body>
<br>
<br>
<form>

<label> Firstname </label>


<input type="text" name="firstname" size="15"/> <br> <br>
<label> Middlename: </label>
<input type="text" name="middlename" size="15"/> <br> <br>
<label> Lastname: </label>
<input type="text" name="lastname" size="15"/> <br>

<br>
<label>
Gender :
</label><br>
<input type="radio" name="male"/> Male <br>
<input type="radio" name="female"/> Female <br>
<input type="radio" name="other"/> Other
<br>
<br>

<label>
Phone :
</label>
<input type="text" name="country code" value="+91" size="2"/>
<input type="text" name="phone" size="10"/> <br> <br>
Address
<br>
<textarea cols="80" rows="5" value="address">
</textarea>
<br> <br>
Email:
<input type="email" id="email" name="email"/> <br>
<br> <br>
Password:
<input type="Password" id="pass" name="pass"> <br>
<br> <br>
Re-type password:
<input type="Password" id="repass" name="repass"> <br> <br>
<input type="button" value="Submit"/>
</form>

DWPD(3350702) 196470307045
2
</body>
</html>

Output:

DWPD(3350702) 196470307045
2

Experiment:-1D
Aim:- Write a code for design menu system using list tag.
Code:
<!DOCTYPE html>
<html lang="en">
<head>
<title>Prac 1D</title>

<style>
*{
padding: 0;
margin: 0;
}
.menu ul li{

list-style: none;
display: inline;
padding: 15px;
}
a{
text-decoration: none;
color:white;
}
.menu{
background: #262626;
line-height: 50px;

}
.menu ul li:hover{
background: #f00000;
transition: .2s;
}
</style>
</head>
<body>
<br><br><br>
<div class="menu">
<ul>
<li><a href="#">Home</a></li>
<li><a href="#">About</a></li>
<li><a href="#">Contact</a></li>
</ul>
</div>
</body>
</html>
Output:

DWPD(3350702) 196470307045
2

Experiment:-1E
Aim:- Write a code for creating static page design using division tag.
Code:
<!DOCTYPE html>
<html lang="en" dir="ltr">
<head>
<style>
*{
margin: 0;
padding: 0;
box-sizing: border-box;
font-family: 'Poppins', sans-serif;
}
nav{
display: flex;
height: 80px;
width: 100%;
background: #1b1b1b;
align-items: center;
justify-content: space-between;
padding: 0 50px 0 100px;
flex-wrap: wrap;
}
nav .logo{
color: white;
font-size: 35px;
font-weight: 600;
}
nav ul{
display: flex;
flex-wrap: wrap;
list-style: none;
}
nav ul li{
margin: 0 5px;
}
nav ul li a{
color: #f2f2f2;
text-decoration: none;
font-size: 18px;
font-weight: 500;
padding: 8px 15px;
border-radius: 5px;
letter-spacing: 1px;
transition: all 0.3s ease;
}
nav ul li a.active,
nav ul li a:hover{
color: #111;
background: #fff;
}
DWPD(3350702) 196470307045
2
.about-tapi-college h1{
text-align: center;
font-size: 40px;
}
.about-tapi-college{
padding-left: 10%;
padding-right: 10%;
}
.about-tapi-college p{
font-size: 22px;
}
hr {
display: block;
margin-top: 0.5em;
margin-bottom: 0.5em;
margin-left: 30%;
margin-right: 30%;
border-color: blue;
border-width: 1px;
}

</style>
</head>
<body>
<nav>
<div class="logo">Tapi Diploma Engineering College</div>
<ul>
<li><a class="active" href="#">Home</a></li>
<li><a href="#">About</a></li>
<li><a href="#">Contact</a></li>
</ul>
</nav>
<div class="img">
<center>
<img src="TAPI-LOGO.jpg" alt="logo" width="300" height="300"><br>
</center>
</div>
<div class="about-tapi-college">
<br><h1>About Tapi College</h1><br><br><hr><br><br>
<p>Tapi Diploma Engineering College, emphasizes to impart quality education to
the students and thereby make dynamic professional in their respective fields and worthy
citizens of great country.</p>
<br>
<p>Rising prestige of Tapi Diploma Engineering College, is not only to provide
higher degree of academic excellence but to present potential youth in the world of
engineering by means of extracting their talent.</p>
<br>
<p>Accredited Diploma Programs: Civil Engineering, Mechanical Engineering and
Computer Engineering Accredited by National Board of Accreditation, New Delhi.</p>
</div>
</body>
</html>

DWPD(3350702) 196470307045
2

Output:

DWPD(3350702) 196470307045
2

Experiment:-1F
Aim:- Design Google Page using HTML5.
Code:
<html>
<head>
<title>Prac 1F</title>
<link href="https://fonts.googleapis.com/css?family=Roboto" rel="stylesheet">
<style>
body {
margin: 0;
padding: 0;
font-family: 'Roboto', sans-serif;
}

header {
width: 100%;
}

ul {
list-style: none;
}

/* NAV BAR */
#nav_bar {
float: right;
}

#nav_bar li {
display: inline-block;
padding: 8px;
}

#nav_bar #sign_in {
background: #4887ef;
margin-right: 25px;
padding: 7px 15px;
border-radius: 3px;
font-weight: bold;
}

.nav-links {
color: #404040;
}

a {
text-decoration: none;
color: inherit;
}

li.nav-links a:hover {
text-decoration: underline;
DWPD(3350702) 196470307045
2
}

#sign_in:hover {
box-shadow: 1px 1px 5px #999;
}

#sign_in {
color: #fff;
}

/* GOOGLE AREA */
.google #google_logo {
text-align: center;
display: block;
margin: 0 auto;
clear: both;
padding-top: 112px;
padding-bottom: 20px;
}

.form {
text-align: center;
}

#form-search {
width: 450px;
line-height: 32px;
padding: 20px 10px;
}

.form #form-search {
padding: 0 8px;
}

#form-search:hover {
border-color: #e4e4e4;
padding-top: 0;
}

.buttons {
text-align: center;
padding-top: 30px;
margin-bottom: 300px;
}

/* FOOTER */
footer {
background: #f2f2f2;
border-top: solid 2px #e4e4e4;
/* position: fixed; */
bottom: 0;
padding-bottom: 0;
width: 100%;

DWPD(3350702) 196470307045
2

footer ul li {
display: inline;
color: #666666;
font-size: 14px;
padding: 13px;
}

footer ul {
float: left;
padding: 1px;
}

footer ul a:hover {
text-decoration: underline;
}

.footer-right {
float: right;
}

</style>
</head>

<body>
<header>
<nav>
<ul id="nav_bar">
<li class="nav-links" id="gmail"><a href="#">Gmail</a></li>
<li class="nav-links"><a href="#">Images</a></li>
<li id="sign_in"><a href="#">Sign In</a></li>
</ul>
</nav>
</header>

<!-- GOOGLE IMG -->


<div class="google">
<a href="#" id="google_logo"><img
src="https://www.google.com/images/srpr/logo11w.png" alt=" photo google-
logo_zpspkcztsjo.png"/></a>
</div>

<!-- FORM SEARCH -->


<div class="form">
<form>
<label for="form-search"></label>
<input type="text" id="form-search" placeholder="Search Google or type URL">
</form>
</div>

<!-- BUTTONS -->


DWPD(3350702) 196470307045
2
<div class= "buttons">
<input type="submit" value="Google Search" id="google_search">
<input type="submit" value="I'm Feeling Lucky" id="im_feeling_lucky">
</div>

<!-- FOOTER -->


<footer>
<ul class="footer-left">
<li><a href="#">Advertising</a></li>
<li><a href="#">Business</a></li>
<li><a href="#">About</a></li>
</ul>
<ul class="footer-right">
<li><a href="#">Privacy</a></li>
<li><a href="#">Terms</a></li>
<li><a href="#">Settings</a></li>
</ul>
</footer>
</body>
</html>

Output:

DWPD(3350702) 196470307045
2

Experiment:-1G
Aim:- Apply CSS formatting to created pages and explore it fully, also use
readymade css templates.

Before:

DWPD(3350702) 196470307045
2

After:

List Of change:
 Change the title of template.
 Change the menu in template.
 Change the Background Image.
 Add About Section.
 Change the Style of Menu.

DWPD(3350702) 196470307045
2

Experiment:-2A
Aim:- Write a PHP script to display Welcome message.
Code:
<?php
echo "Welcome to PHP Programming !!!!"."<br>";
echo "This", " string", " was", " made", " with multiple parameters.";
echo ("Welcome to PHP Programming !!!!"."<br>");
print("Welcome to PHP"."<br>");
print "Hello World";
?>

Output:

DWPD(3350702) 196470307045
2

Experiment:-2B
Aim:- Write a PHP script to demonstrate arithmetic operators, comparison
operator,and logical operator.

Code:
<?php
$a=10;
$b=20;
echo "Arithmetic Operators:-","<br><br>";
$c=$a+$b;
echo $c."<br>";

$c=$a-$b;
echo $c."<br>";

$c=$a*$b;
echo $c."<br>";

$c=$a/$b;
echo $c."<br>";

$c=$a%$b;
echo $c."<br><br>";

echo "Comparison Operators:-","<br><br>";


if($a==$b)
{
echo "Both are equal"."<br>";
}

if($a===$b)
{
echo "Both are equal with same type"."<br>";
}

if($a!=$b)
{
echo "Both are Different"."<br>";
}

if($a<>$b)
{
echo "Both are Different"."<br>";
}

if($a!==$b)
{
echo "Both are Different but have same data type"."<br>";
}

DWPD(3350702) 196470307045
2

if($a>$b)
{
echo "a is greater than b"."<br>";
}

if($a<$b)
{
echo "b is greater than a"."<br>";
}

if($a>=$b)
{
echo "a is greater or equal to b"."<br>";
}

if($a<=$b)
{
echo "a is less than b"."<br><br>";
}

echo "Logical Operators:-","<br><br>";


if($a<$b && $b>$a)
{
echo "a is less than b and b is grater than a"."<br>";
}

if($a>$b || $b>$a)
{
echo "a is greater than b or b is grater than a"."<br>";
}

if(!isset($_SESSION['user']))
{
echo "User is not login"."<br>";
}
?>

DWPD(3350702) 196470307045
2

Output:

DWPD(3350702) 196470307045
2

Experiment:-2C
Aim:- Write a PHP script to get type of variable using gettype() and set
type of variable using settype().

Code:
<?php
$a=10;
echo "variable a is ".gettype($a)."<br>";

settype($a,"string");

echo "now variable a is ".gettype($a);


?>

Output:

DWPD(3350702) 196470307045
2

Experiment:-2D
Aim:- Write a PHP script to set type of variable using type casting.

Code:
<?php
$a=10;
echo "variable a is --> ".gettype($a)."<br>";

$b=(string)$a;

echo "variable b is --> ".gettype($b);


?>

Output:

DWPD(3350702) 196470307045
2

Experiment:-2E
Aim:- Write PHP Script to print Fibonacci series.

Code:
<head>
<title>Prac 2E</title>
</head>
<body>
<form method="post">
Enter Number to Create Fibonacci Series: <input type="text" name="Number"><br/>
<input type="submit" name="submit" value="submit">
</form>
</body>
</html>
<?php
if(isset($_POST['submit']))
{
$Number=$_POST['Number'];
$num = 0;
$n1 = 0;
$n2 = 1;
echo "\n";
echo $n1.' '.$n2.' ';
while ($num < $Number - 2)
{
$n3 = $n2 + $n1;
echo $n3.' ';
$n1 = $n2;
$n2 = $n3;
$num = $num + 1;
}
}
?>

Output:

DWPD(3350702) 196470307045
2

Experiment:-2F
Aim:- Write PHP Script to calculate total marks of student and display
grade.

Code:
<html>
<head>
<title>Prac 2F</title>
</head>
<body>
<form method="post">
DWPD <input type="text" name="dwpd"><br/>
JAVA <input type="text" name="java"><br/>
CMT <input type="text" name="cmt"><br/>
CNS <input type="text" name="cns"><br/>
<input type="submit" name="submit" value="Get Grade">
</form>
</body>
</html>
<?php
if(isset($_POST['submit']))
{
$dwpd=$_POST['dwpd'];
$java=$_POST['java'];
$cmt=$_POST['cmt'];
$cns=$_POST['cns'];
$totalm=100*4;
$total=$dwpd+$java+$cmt+$cns;
echo "Marks obtained in DWPD is $dwpd"."<br>";

echo "Marks obtained in JAVA is $java"."<br>";


echo "Marks obtained in CMT is $cmt"."<br>";
echo "Marks obtained in CNS is $cns"."<br>";
echo "Total marks obtained $total out of $totalm"."<br>";
$average=$total*100/$totalm;
echo "And The result is : ";

switch($average)
{
case $average<=32:
echo "<h1>failed</h1>";
break;
case $average>=33 && $average<=50:
echo "Third class <h1>BB Grade</h1>";
break;
case $average>=50 && $average<=60:
echo "Second class <h1>BA Grade</h1>";
break;
case $average>=60 && $average<=700:
echo "First class<h1>AB Grade</h1>";
DWPD(3350702) 196470307045
2
break;
case $average>=70 && $average<=100:
echo "Distinction <h1>AA Grade</h1>";
break;
}
}
?>

Output:

DWPD(3350702) 196470307045
2

Experiment:-2G
Aim:- Write PHP Script to find maximum number out of three given numbers.
Code:
<html>
<head>
<title>Prac 2G</title>
</head>
<body>
<form method="post">
Enter Value to Find Maximum Number:-<br><br>
a <input type="text" name="a"><br/>
b <input type="text" name="b"><br/>
c <input type="text" name="c"><br/>
<input type="submit" name="submit" value="submit">
</form>
</body>
</html>
<?php
if(isset($_POST['submit']))
{
$a=$_POST['a'];
$b=$_POST['b'];
$c=$_POST['c'];
if($a>$b && $a>$c)
{
echo "a is max";
}
else if($b>$c)
{
echo "b is max";
}
else
{
echo "c is max";
}
}
?>
Output:

DWPD(3350702) 196470307045
2

Experiment:-3A
Aim:- Write PHP Script for FOREACH loop execution using index array &
associative array.

Code:
<?php
//Index Array
$arr=array(1,2,3,4,5);
foreach($arr as $a)
{
echo "$a"."<br>";
}
//Assciative Array
$arr1=array(1=>"A",2=>"B",3=>"C",4=>"D",5=>"F");
foreach($arr1 as $a => $b)
{
echo "$a => $b"."<br>";
}
?>

Output:

DWPD(3350702) 196470307045
2

Experiment:-3B
Aim:-Write PHP Script using two dimensional arrays such as addition of two
2*2 matrices.
Code:
<?php
$a=array(array(1,2),array(3,4));
$b=array(array(5,6),array(7,8));
echo "First Matrix<br>";
for($i=0;$i<2;$i++)
{
for($j=0;$j<2;$j++)
{
echo $a[$i][$j]." ";
}
echo "<br>";
}
echo "Second Matrix<br>";
for($i=0;$i<2;$i++)
{
for($j=0;$j<2;$j++)
{
echo $b[$i][$j]." ";
}
echo "<br>";
}
echo "Sum Of Two Matrix<br>";
for($i=0;$i<2;$i++)
{
for($j=0;$j<2;$j++)
{
echo $a[$i][$j]+$b[$i][$j]." ";
}
echo "<br>";
}
?>
Output:

DWPD(3350702) 196470307045
2

Experiment:-3C
Aim:-Write PHP Script using user defined function.
Code:
<?php
//Function Without Array
function f1()
{
echo "hello word<br>" ;
}
//Function With Array
function f2($a,$b)
{
echo $a+$b."<br>";
}
//Function With Return Type
function f3($a,$b)
{
return $a+$b;
}
//Function With Default Argument Value
function f4($a=1,$b=2,$c=3)
{
echo $a." ".$b." ".$c."<br>";
}
//Function With Vraiable length argumnet
function f5()
{
echo func_num_args()."<br>";
echo func_get_arg(0)."<br>";
print_r(func_get_args());
}
f1();
f2(7,9);
echo f3(11,12)."<br>";
f4(17,18);
f5(1,2,3,4,5);
?>
Output:

DWPD(3350702) 196470307045
2

Experiment:-3D
Aim:-Write PHP Script to demonstrate string function.
Code:
<?php
echo chr(86)."<br>";
echo ord("H")."<br>";
echo ord("Hello")."<br>";
echo strtolower("VISHV")."<br>";
echo strtoupper("vishv")."<br>";
echo strlen("Welcome To PHP")."<br>";
echo trim("Hello","o")."<br>";
echo ltrim(" Hello")."<br>";
echo rtrim("Hello ")."<br>";
echo substr("abcdef",-2)."<br>";
echo substr("abcdef",-3,1)."<br>";
echo substr("abcdef",0,-1)."<br>";
echo substr("abcdef",2,-1)."<br>";
echo substr("abcdef",4,-4)."<br>";
echo strcmp("hello","hello")."<br>";
echo strcmp("heIIo","hi")."<br>";
echo strcmp("hi","hello")."<br>";
echo strcasecmp("hello","Hello")."<br>";
echo strpos("welcome","e")."<br>";
echo strpos("welcome","l")."<br>";
echo strrpos("welcome","l")."<br>";
echo strstr("Hello world!","wor")."<br>";
echo stristr("Hello world!","Wor")."<br>";
echo str_replace("JAVA","PHP","Welcome to JAVA")."<br>";
echo strrev("vishv")."<br>";
$name="Vishv";
echo "My name is ".$name."<br>";
Print "My name is ".$name."<br>";
?>

DWPD(3350702) 196470307045
2

Output:

DWPD(3350702) 196470307045
2

Experiment:-3E
Aim:-Write PHP Script to demonstrate Math functions.
Code:
<?php
echo abs(-6)."<br>";
echo ceil(0.5)."<br>";
echo ceil(-8.5)."<br>";
echo floor(0.4)."<br>";
echo floor(3.9)."<br>";
echo round(8.55)."<br>";
echo round(9.415,2)."<br>";
echo round(0.77)."<br>";
echo fmod(8,3)."<br>";
echo min(7,3,-5,9)."<br>";
echo max(7,3,-5,9)."<br>";
echo pow(9,3)."<br>";
echo sqrt(81)."<br>";
echo sqrt(-81)."<br>";
echo rand(1,1000)."<br>";
?>

Output:

DWPD(3350702) 196470307045
2

Experiment:-3F
Aim:-Write PHP Script to display date formats using date functions.
Code:
<?php
echo date("h:i:s A")."<br>";
echo date("H:i:s")."<br>";
echo date("d/m/y")."<br>";
echo date("d M Y")."<br>";
print_r (getdate());
echo "<br>";
var_dump(checkdate(2,29,2021));
echo "<br>";
var_dump(checkdate(2,29,2020));
echo "<br>";
echo time()."<br>";
echo (date("d-M-Y",mktime(0,0,0,12,36,2020))."<br>");
echo (date("d-M-Y",mktime(0,0,0,1,1,20))."<br>");
?>

Output:

DWPD(3350702) 196470307045
2

Experiment:-4A
Aim:- Create form using text box, check box, radio button, select, submit
button. And display user inserted value in new PHP page (e.g. student
registration/ inventory/ library form).
Code 4A.php:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Prac 4A</title>
</head>
<body>
<center>
<br><br>
<h1>Registration Form</h1><br><br>
<table border="1">
<form action="4A(1).php" method="POST">
<tr>
<th><label for="name">Name:</label></th>
<td><input type="text" name="name" placeholder="Enter Name"><br></td>
</tr>
<tr>
<th><label for="enno">Enrollment No.:</label></th>
<td><input type="number" name="enno" placeholder="Enter Enrollment
No"><br></td>
</tr>
<tr>
<th><label for="mono">Mobile No.:</label></th>
<td><input type="number" name="mono" placeholder="Enter Mobile No"><br></td>
</tr>
<tr>
<th><label for="email">E-Mail:</label></th>
<td><input type="text" name="email" placeholder="Enter Email"><br></td>
</tr>
<tr>
<th><label for="course">Course:</label></th>
<td><select name="course">
<option value="select">--Select Course--</option>
<option value="Degree Engineering">Degree Engineering</option>
<option value="Pharmacy">Pharmacy</option>
<option value="Diploma Engineering">Diploma Engineering</option>
<option value="Master of Engineering">Master of Engineering</option>
<option value="CPD">CPD</option>
</select><br></td>
</tr>
<tr>
<th><label for="dob">Date Of Birth:</label></th>
<td><select name="date">

DWPD(3350702) 196470307045
2
<option value="date">Date</option>
<?php
for($date=1; $date<=31; $date++)
{
echo '<option value="'.$date.'">'.$date.'</option>';
}
?>
</select>
<select name="month">
<option value="month">Month</option>
<?php
for($month=1; $month<=12; $month++)
{
echo '<option value="'.$month.'">'.$month.'</option>';
}
?>
</select>
<select name="year">
<option value="year">Year</option>
<?php
for($year=1900; $year<=date('Y'); $year++)
{
echo '<option value="'.$year.'">'.$year.'</option>';
}
?>
</select><br></td>
</tr>
<tr>
<th><label for="address">Address</label></th>
<td><textarea name="address" id="address" cols="25" rows="3"
placeholder="Enter Address Here..."></textarea><br></td>
</tr>

<tr>
<th><label for="gender">Gender:</label></th>
<td><input type="radio" name="gender" value="male">Male<br>
<input type="radio" name="gender" value="female">FeMale<br>
<input type="radio" name="gender" value="other">other<br></td>
</tr>
<tr>
<th><label for="hobby">Hobby:</label></th>
<td><input type="checkbox" name="hobby[]" value="cricket">cricket<br>
<input type="checkbox" name="hobby[]" value="hockey">Hockey<br>
<input type="checkbox" name="hobby[]" value="chess">Chess<br></td>
</tr>
<tr>
<td colspan=2><br><center><input type="submit" name="submit"
value="Submit"></center><br></td>
</tr>

</form>
</table>
</center>
DWPD(3350702) 196470307045
2
</body>
</html>

Code 4A(1).php:
<?php
$name=$_POST['name'];
$enno=$_POST['enno'];
$mono=$_POST['mono'];
$email=$_POST['email'];
$course=$_POST['course'];
$date=$_POST['date'];
$month=$_POST['month'];
$year=$_POST['year'];
$address=$_POST['address'];
$gender=$_POST['gender'];

echo "Your Name is ".$name."<br>";


echo "Your Enrollment No. is ".$enno."<br>";
echo "Your Mobile No. is ".$mono."<br>";
echo "Your E-Mail is ".$email."<br>";
echo "Your Course is ".$course."<br>";
echo "Your Birth Of Date is "."$date/$month/$year"."<br>";
echo "Your Address is ".$address."<br>";
echo "Your gender is ".$gender."<br>";
echo "Your Hobby ";
foreach($_POST['hobby'] as $check)
{
echo $check." ";
}
?>

DWPD(3350702) 196470307045
2

Output 4A.php:

Output 4A(1).php:

DWPD(3350702) 196470307045
2

Experiment:-4B
Aim:- Write two different PHP script to demonstrate passing variables
through a URL.
Code 4B.php:
<form action="4B(1).php" method="GET">
<label for="fname">First Name:</label>
<input type="text" name="fname" placeholder="Enter First Name"><br><br>
<label for="lname">Last Name:</label>
<input type="text" name="lname" placeholder="Enter Last Name"><br><br>
<label for="enno">Enrollment No.:</label>
<input type="number" name="enno" placeholder="Enter Enrollment No."><br><br>
<input type="submit" name="submit" value="Submit">
</form>

Code 4B(1).php:
<?php
$fname=$_GET['fname'];
$lname=$_GET['lname'];
$enno=$_GET['enno'];

echo "Your First Name is ".$fname."<br>";


echo "Your Last Name is ".$lname."<br>";
echo "Your Enrollment No. is ".$enno."<br>";
?>

Output 4B.php:

DWPD(3350702) 196470307045
2

Output 4B.php(1):

DWPD(3350702) 196470307045
2

Experiment:-4C
Aim:- Write two different PHP script to demonstrate passing variables
through Hidden Variables.
Code 4C.php:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Prac 4C</title>
</head>
<body>
<center>
<br><br>
<h1>Registration Form</h1><br><br>
<table border="1">
<form action="4C(1).php" method="POST">
<tr>
<th><label for="name">Name:</label></th>
<td><input type="text" name="name" placeholder="Enter Name"><br></td>
</tr>
<tr>
<th><label for="enno">Enrollment No.:</label></th>
<td><input type="number" name="enno" placeholder="Enter Enrollment
No"><br></td>
</tr>
<tr>
<th><label for="mono">Mobile No.:</label></th>
<td><input type="number" name="mono" placeholder="Enter Mobile No"><br></td>
</tr>
<tr>
<th><label for="email">E-Mail:</label></th>
<td><input type="text" name="email" placeholder="Enter Email"><br></td>
</tr>
<tr>
<th><label for="course">Course:</label></th>
<td><select name="course">
<option value="select">--Select Course--</option>
<option value="Degree Engineering">Degree Engineering</option>
<option value="Pharmacy">Pharmacy</option>
<option value="Diploma Engineering">Diploma Engineering</option>
<option value="Master of Engineering">Master of Engineering</option>
<option value="CPD">CPD</option>
</select><br></td>
</tr>
<tr>
<td colspan=2><br><center><input type="submit" name="next"
value="Next"></center><br></td>
</tr>

DWPD(3350702) 196470307045
2
</form>
</table>
</center>
</body>
</html>

Code 4C(1).php:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Prac 4C(1)</title>
</head>
<body>
<center>
<br><br>
<h1>Registration Form</h1><br><br>
<table border="1">
<form action="4C(2).php" method="POST">
<input type="hidden" name="name" value="<?php echo $_POST['name']; ?>">
<input type="hidden" name="enno" value="<?php echo $_POST['enno']; ?>">
<input type="hidden" name="mono" value="<?php echo $_POST['mono']; ?>">
<input type="hidden" name="email" value="<?php echo $_POST['email']; ?>">
<input type="hidden" name="course"value="<?php echo $_POST['course']; ?>">
<tr>
<th><label for="dob">Date Of Birth:</label></th>
<td><select name="date">
<option value="date">Date</option>
<?php
for($date=1; $date<=31; $date++)
{
echo '<option value="'.$date.'">'.$date.'</option>';
}
?>
</select>
<select name="month">
<option value="month">Month</option>
<?php
for($month=1; $month<=12; $month++)
{
echo '<option value="'.$month.'">'.$month.'</option>';
}
?>
</select>
<select name="year">
<option value="year">Year</option>
<?php
for($year=1900; $year<=date('Y'); $year++)
{
echo '<option value="'.$year.'">'.$year.'</option>';

DWPD(3350702) 196470307045
2
}
?>
</select><br></td>
</tr>
<tr>
<th><label for="address">Address</label></th>
<td><textarea name="address" id="address" cols="25" rows="3"
placeholder="Enter Address Here..."></textarea><br></td>
</tr>

<tr>
<th><label for="gender">Gender:</label></th>
<td><input type="radio" name="gender" value="male">Male<br>
<input type="radio" name="gender" value="female">FeMale<br>
<input type="radio" name="gender" value="other">other<br></td>
</tr>
<tr>
<th><label for="hobby">Hobby:</label></th>
<td><input type="checkbox" name="hobby[]" value="cricket">cricket<br>
<input type="checkbox" name="hobby[]" value="hockey">Hockey<br>
<input type="checkbox" name="hobby[]" value="chess">Chess<br></td>
</tr>
<tr>
<td colspan=2><br><center><input type="submit" name="submit"
value="Submit"></center><br></td>
</tr>

</form>
</table>
</center>
</body>
</html>

Code 4C(2).php:
<?php
$name=$_POST['name'];
$enno=$_POST['enno'];
$mono=$_POST['mono'];
$email=$_POST['email'];
$course=$_POST['course'];
$date=$_POST['date'];
$month=$_POST['month'];
$year=$_POST['year'];
$address=$_POST['address'];
$gender=$_POST['gender'];

echo "Your Name is ".$name."<br>";


echo "Your Enrollment No. is ".$enno."<br>";
echo "Your Mobile No. is ".$mono."<br>";
echo "Your E-Mail is ".$email."<br>";
echo "Your Course is ".$course."<br>";
echo "Your Birth Of Date is "."$date/$month/$year"."<br>";

DWPD(3350702) 196470307045
2
echo "Your Address is ".$address."<br>";
echo "Your gender is ".$gender."<br>";
echo "Your Hobby ";
foreach($_POST['hobby'] as $check)
{
echo $check." ";
}
?>

Output 4C.php:

DWPD(3350702) 196470307045
2

Output 4C(1).php:

Output 4C(2).php:

DWPD(3350702) 196470307045
2

Experiment:-4D
Aim:- Write two different PHP script to demonstrate passing variables with
sessions
Code 4D.php:
<form action="4D(1).php" method="POST">
Username: <input type="text" name="uname"><br><br>
Age: <input type="text" name="age"><br><br>
<input type="submit" name="Submit">
</form>

Code 4D(1).php:
<?php
session_start();

$_SESSION['uname']=$_POST['uname'];
$_SESSION['age']=$_POST['age'];

echo "Your Username is ".$_SESSION['uname']."<br>";


echo "Your Age is ".$_SESSION['age'];
?>

Output 4D.php:

Output 4D(1).php:

DWPD(3350702) 196470307045
2

Experiment:-4E
Aim:- Write PHP script to demonstrate passing variables with cookies.
Code 4E.php:
<form action="4E(1).php" method="POST">
Username: <input type="text" name="uname"><br><br>
Age: <input type="text" name="age"><br><br>
<input type="submit" name="Submit">
</form>

Code 4E(1).php:
<?php
$a=$_POST['uname'];
$b=$_POST['age'];
setcookie("uname",$a,Time()+3600);
setcookie("age",$b,Time()+3600);

$a=$_COOKIE['uname'];
$b=$_COOKIE['age'];
echo "Your Username is ".$a."<br>";
echo "Your Age is ".$b;
?>

Output 4E.php:

Output 4E(1).php:

DWPD(3350702) 196470307045
2

Experiment:-4F
Aim:- Write a program to keep track of how many times a visitor has loaded
the page.
Code:
<?php
session_start();
if(isset($_SESSION['count']))
{
$_SESSION['count']+=1;
echo "Pageview: ".$_SESSION['count'];
}
else
{
$_SESSION['count']=1;
echo "Pageview: ".$_SESSION['count'];
}
?>

Output:

DWPD(3350702) 196470307045
2

Experiment:-5A
Aim:- Create database using phpMyAdmin.
Steps:
Step 1: Go to PHP myadmin: Open your browser and type http://localhost/phpmyadmin/ You
will get following window,

Step 2:Select Database Menu item: Click on Database Menu Where we marked.

Step 3: Create Database: Type your database name, then click ‘create’ Button.

Step 4: Your Database Created. You can find that one on leftside.

DWPD(3350702) 196470307045
2

Experiment:-5B
Aim:- Write a PHP script to connect MYSQL server from your website.
Code:
<?php
$dbhost="localhost";
$dbuser="root";
$dbpass="";
$conn = mysqli_connect($dbhost,$dbuser,$dbpass);

if(!$conn)
{
die('Could not connect: ' . mysqli_error());
}
else{
echo "<h1>Successfully Connected With Server<h1>";
}
?>

Output:

DWPD(3350702) 196470307045
2

Experiment:-5C
Aim:- Write a PHP script to create and drop database.
Code:
<form action="" method="POST">
<button name="create">Create Database</button>
<button name="drop">Drop Database</button>
</form>
<br>
<?php
$dbhost="localhost";
$dbuser="root";
$dbpass="";
$conn = mysqli_connect($dbhost,$dbuser,$dbpass);

if(!$conn)
{
die('Could not connect: ' . mysqli_error());
}

if(isset($_POST['create']))
{
$sql = 'CREATE DATABASE my_db';

$result = mysqli_query($conn,$sql);
if($result)
{
echo "<h1>Database Created Successfully</h1>";
}
}
elseif(isset($_POST['drop']))
{
$sql1 = 'DROP DATABASE my_db';
$result1 = mysqli_query($conn,$sql1);
if($result1)
{
echo "<h1>Database Drop Successfully</h1>";
}
}
?>

DWPD(3350702) 196470307045
2

Output:

DWPD(3350702) 196470307045
2

Experiment:-5D
Aim:- Write a program to read input data, from table and display all these
information in table format on output screen.
Code:
<?php
$dbhost="localhost";
$dbuser="root";
$dbpass="";
$dbname="mydb";
$conn = mysqli_connect($dbhost,$dbuser,$dbpass,$dbname);

if(!$conn)
{
die('Could not connect: ' . mysqli_error());
}

mysqli_select_db($conn,'mydb');

$result1 = mysqli_query($conn,'SELECT * FROM student');


echo "<table border='1'>
<tr><th>ID</th><th>Name</th><th>Department</th><th>Semester</th><th>Gender</th></tr>";
while($row = mysqli_fetch_array($result1))
{
echo "<tr>";
echo "<td>".$row['ID']."</td>";
echo "<td>".$row['Name']."</td>";
echo "<td>".$row['Department']."</td>";
echo "<td>".$row['Semester']."</td>";
echo "<td>".$row['Gender']."</td>";
echo "</tr>";
}
echo "</table>"

?>
Output:

DWPD(3350702) 196470307045
2

Experiment:-5E
Aim:- Write a program to manipulate data from table and display all this
information using table format.
Code:
<table>
<form action="" method="POST">
<tr>
<th><label for="ID">ID:</label></th>
<td><input type="number" name="ID" placeholder="Enter ID"><br></td>
</tr>
<tr>
<th><label for="name">Name:</label></th>
<td><input type="text" name="Name" placeholder="Enter Name"><br></td>
</tr>
<tr>
<th><label for="Department">Department:</label></th>
<td><input type="text" name="Department" placeholder="Enter Department"><br></td>
</tr>
<tr>
<th><label for="Semester">Semester:</label></th>
<td><input type="number" name="Semester" placeholder="Enter Semester"><br></td>
</tr>
<tr>
<th><label for="Gender">Gender:</label></th>
<td><input type="radio" name="Gender" value="Male">Male<br>
<input type="radio" name="Gender" value="FeMale">FeMale<br></td>
</tr>
<tr>
<td colspan="2"><center><input type="submit" name="submit"
value="Submit"></center></td>
</tr>
</form>
</table>
<br>
<br>
<h1>Student Data</h1>
<?php
$dbhost="localhost";
$dbuser="root";
$dbpass="";
$dbname="mydb";
$conn = mysqli_connect($dbhost,$dbuser,$dbpass,$dbname);

if(!$conn)
{
die('Could not connect: ' . mysqli_error());
}

mysqli_select_db($conn,'mydb');

DWPD(3350702) 196470307045
2
//Add Data In Table

if(isset($_POST['submit']))
{
$ID=$_POST['ID'];
$Name=$_POST['Name'];
$Department=$_POST['Department'];
$Semester=$_POST['Semester'];
$Gender=$_POST['Gender'];

$sql = "INSERT INTO `student1` (`ID`, `Name`, `Department`, `Semester`, `Gender`)


VALUES ('$ID', '$Name', '$Department', '$Semester', '$Gender')";

$result = mysqli_query($conn,$sql);
if(!$result)
{
die('Could not insert data:' . mysqli_error());
}

}
//Show Table Data

$result1 = mysqli_query($conn,'SELECT * FROM student1');

echo "<table border='1'>


<tr><th>ID</th><th>Name</th><th>Department</th><th>Semester</th><th>Gender</th></tr>";
while($row = mysqli_fetch_array($result1))
{
echo "<tr>";
echo "<td>".$row['ID']."</td>";
echo "<td>".$row['Name']."</td>";
echo "<td>".$row['Department']."</td>";
echo "<td>".$row['Semester']."</td>";
echo "<td>".$row['Gender']."</td>";
echo "</tr>";
}
echo "</table>";
?>

DWPD(3350702) 196470307045
2

Output:

DWPD(3350702) 196470307045
2

Experiment:-5F
Aim:- Develop small PHP application(s) using forms and database.
Code 5F(1).php:
<h1>Registration Forms</h1>

<table>
<form action="" method="POST">
<tr>
<th><label for="enno">Enrollment No.:</label></th>
<td><input type="number" name="enno" placeholder="Enter Enrollment No."><br></td>
</tr>
<tr>
<th><label for="name">Name:</label></th>
<td><input type="text" name="name" placeholder="Enter Name"><br></td>
</tr>
<tr>
<th><label for="dept">Department:</label></th>
<td><input type="text" name="dept" placeholder="Enter Department"><br></td>
</tr>
<tr>
<th><label for="sem">Semester:</label></th>
<td><select name="sem">
<?php
for($sem=1; $sem<=8; $sem++)
{
echo '<option value="'.$sem.'">'.$sem.'</option>';
}
?>
</select><br></td>
</tr>
<tr>
<th><label for="email">E-Mail:</label></th>
<td><input type="text" name="email" placeholder="Enter E-Mail"><br></td>
</tr>
<tr>
<th><label for="pass">Password:</label></th>
<td><input type="password" name="pass" placeholder="Enter Password"><br></td>
</tr>
<tr>
<td colspan="2"><center><br><input type="submit" name="submit"
value="Submit"></center></td>
</tr>
</form>
</table>
<h3>Already Register? <a href="5f(2).php">Login</a></h3>

<?php
$dbhost="localhost";
$dbuser="root";
$dbpass="";
$dbname="app";
DWPD(3350702) 196470307045
2
$conn = mysqli_connect($dbhost,$dbuser,$dbpass,$dbname);

if(!$conn)
{
die('Could not connect Database: ' . mysqli_error());
}
mysqli_select_db($conn,'app');

if(isset($_POST['submit']))
{
$enno=$_POST['enno'];
$name=$_POST['name'];
$dept=$_POST['dept'];
$sem=$_POST['sem'];
$email=$_POST['email'];
$pass=$_POST['pass'];

$sql = "INSERT INTO `register` (`enno`, `name`, `dept`, `sem`, `email`, `pass`)
VALUES ('$enno', '$name', '$dept', '$sem', '$email', '$pass')";

$result = mysqli_query($conn,$sql);
if($result)
{
echo "<h3>Successfully Data Inserted in Table</h3>";
}

}
?>

Code 5F(2).php:
<h1>Login</h1>
<table>
<form action="" method="POST">
<tr>
<th><label for="email">E-Mail:</label></th>
<td><input type="text" name="email" placeholder="Enter E-Mail"><br></td>
</tr>
<tr>
<th><label for="pass">Password:</label></th>
<td><input type="password" name="pass" placeholder="Enter Password"><br></td>
</tr>
<tr>
<td colspan="2"><center><br><input type="submit" name="submit"
value="Submit"></center></td>
</tr>
</form>
</table>
<?php
session_start();
$dbhost="localhost";
$dbuser="root";
$dbpass="";

DWPD(3350702) 196470307045
2
$dbname="app";
$conn = mysqli_connect($dbhost,$dbuser,$dbpass,$dbname);

if(!$conn)
{
die('Could not connect Database: ' . mysqli_error());
}
mysqli_select_db($conn,'app');
if(isset($_POST['submit']))
{
$email=$_POST['email'];
$pass=$_POST['pass'];
$_SESSION['email']=$email;
$_SESSION['pass']=$pass;

$sql = "SELECT * FROM register WHERE email='$email' && pass='$pass'";


$result = mysqli_query($conn,$sql);

if($result)
{
header("location:5F(3).php");
}
elseif(isset($_SESSION['error']))
{
session_destroy();
}
else
{
$_SESSION['error']="Invalid Usernaame and Password";
echo $_SESSION['error'];
}
}

?>

Code 5F(3).php:
<?php
session_start();
$dbhost="localhost";
$dbuser="root";
$dbpass="";
$dbname="app";
$conn = mysqli_connect($dbhost,$dbuser,$dbpass,$dbname);

if(!$conn)
{
die('Could not connect Database: ' . mysqli_error());
}
mysqli_select_db($conn,'app');
$email=$_SESSION['email'];
$pass=$_SESSION['pass'];
$sql="SELECT * FROM register where email='$email' && pass='$pass'";

DWPD(3350702) 196470307045
2
$result = mysqli_query($conn,$sql);
while($raw=mysqli_fetch_assoc($result))
{
echo "<h3>Welcome ".$raw['name']."</h3>";
echo "<h4>Enrollment No.: ".$raw['enno']."</h4>";
echo "<h4>Department : ".$raw['dept']."</h4>";
echo "<h4>Semester : ".$raw['sem']."</h4>";
echo "<h4>email : ".$raw['email']."</h4>";
}
?>
<form action="" method="POST">
<button name="logout">Logout</button>
<button name="edit">Edit Data</button>
</form>
<?php
if(isset($_POST['logout']))
{
header("location:5F(1).php");
}
elseif(isset($_POST['edit']))
{
header("location:5F(4).php");
}
?>

Code 5F(4).php:
<h1>Edit Data</h1>

<table>
<form action="" method="POST">
<tr>
<th><label for="enno">Enrollment No.:</label></th>
<td><input type="number" name="enno" placeholder="Enter Enrollment No."><br></td>
</tr>
<tr>
<th><label for="name">Name:</label></th>
<td><input type="text" name="name" placeholder="Enter Name"><br></td>
</tr>
<tr>
<th><label for="dept">Department:</label></th>
<td><input type="text" name="dept" placeholder="Enter Department"><br></td>
</tr>
<tr>
<th><label for="sem">Semester:</label></th>
<td><select name="sem">
<?php
for($sem=1; $sem<=8; $sem++)
{
echo '<option value="'.$sem.'">'.$sem.'</option>';
}
?>
</select><br></td>

DWPD(3350702) 196470307045
2
</tr>
<tr>
<th><label for="email">E-Mail:</label></th>
<td><input type="text" name="email" placeholder="Enter E-Mail"><br></td>
</tr>
<tr>
<th><label for="pass">Password:</label></th>
<td><input type="password" name="pass" placeholder="Enter Password"><br></td>
</tr>
<tr>
<td colspan="2"><center><br><input type="submit" name="submit"
value="Submit"></center></td>
</tr>
</form>
</table>

<?php
session_start();
$dbhost="localhost";
$dbuser="root";
$dbpass="";
$dbname="app";
$conn = mysqli_connect($dbhost,$dbuser,$dbpass,$dbname);

if(!$conn)
{
die('Could not connect Database: ' . mysqli_error());
}
mysqli_select_db($conn,'app');

if(isset($_POST['submit']))
{
$enno=$_POST['enno'];
$name=$_POST['name'];
$dept=$_POST['dept'];
$sem=$_POST['sem'];
$email=$_POST['email'];
$pass=$_POST['pass'];

$email=$_SESSION['email'];
$pass=$_SESSION['pass'];

$sql = "UPDATE register SET `enno`='$enno' , `name`='$name' , `dept`='$dept' ,


`sem`='$sem' , `email`='$email' , `pass`='$pass' WHERE email='$email' && pass='$pass'";
$result = mysqli_query($conn,$sql);
if($result)
{
echo "<h1>Your Data Updated</h1>";
}
}

?>

DWPD(3350702) 196470307045
2

Output 5F(1).php:

Output 5F(2).php:

DWPD(3350702) 196470307045
2

Output 5F(3).php:

Output 5F(4).php:

DWPD(3350702) 196470307045

You might also like