You are on page 1of 45

Practical-1

Aim:- Design PHP based web pages using correct PHP,CSS and XHTML syntax
structure.

Source code:-
<!DOCTYPE html>

<html lang="en">

<head>

<meta charset="UTF-8">

<meta http-equiv="X-UA-Compatible" content="IE=edge">

<meta name="viewport" content="width=, initial-scale=1.0">

<title>Document</title>

<style>

.top{

overflow: hidden;

background-color: black;

.top a{

color:

gold;

padding: 20px 15px;

font-size: 20px;

float: right;

text-decoration: none;

.alo{

padding: 30px 20px;

1
</style>

</head>

<body>

<div class="top">

<a href="">Home</a>

<a href="">About Us</a>

<a href="">Books categories</a>

<a href="">Authors</a>

<a href="">Contact Us</a>

</div>

<!-- <div ></div> -->

<DIV style="text-align: center;"> <marquee behavior="" direction="" style="color:green; font-size: 75px;">Govt Polytechnic
Rajpur (Sadhaura) </marquee>

<img src="gprs.jpg"

alt="img. not found" style="text-align: center;"></DIV>

<div>

<h1 style="color: crimson; padding-bottom:0px;">About college</h1>

<p>Government Polytechnic, Rajpur is situated just

3.5Km from Sadhaura , District Yamuna Nagar (Haryana). This district is known

for its production of Steel products /Utensils /Plywood etc. At present, Sadhaura

is witnessing very good growth of industries in nearby towns like Kala Amb (H.P.). In

the changing scenario, when the multi-national companies are being attracted towards

India, the surroundings of this city is also not lagging behind. Many dynamic entrepreneurs

are coming to the city and establishing different types of industries.</p>

</div>

<DIV style="float: left;" class="alo"><img src="gprs front.jpg" alt="img not found"></DIV>

<div style="float: left;" class="alo"><img src="gprs 3.jpg" alt=" img not found "></div>

<div class="alo"><img src="gprs 4.jpg" alt=" img not found "></div>

</body>

</html>

2
Output :

3
Practical-2.a

Aim:- Create web form and page that properly use HTTP GET Protocol
Source code:-
Form.html
<!DOCTYPE html>

<html lang="en">

<head>

<meta charset="UTF-8">

<meta name="viewport" content="width=device-width, initial-scale=1.0">

<title>Document</title>

</head>

<body>

<h1> Student Registration form</h1>

<form action="getph.php" method="get">

<div><p>Name<input type="text" name="name"></p></div>

<div><p>Roll No<input type="number"></p></div>

Father's Name:<input type="text"Name="Father's Name"><br><br>

Mother's name:<input type="text" name="Mother's Name"><br><br>

<div><p>Mobile No.<input type="number" name="number"></p></div>

<p>date of birth</p>

<input type="text" name="day" size="2"/>

<input type="text" name="month" size="2"/>

<input type="text" name="year" size="4"/><br><br>

<div><p>Gender<input type="radio" name="gen">Male<input type="radio" name="gen">Female</p></div>

<div><p>Category</p><p><input type="radio" name="cat">Gen. </p><p><input type="radio"


name="cat">Sc</p><p><input type="radio" name="cat">Bc</p></div>

Address:<input type="text" name="Address" size=50/><br><br>

<div><p>Student Id <input type="text" name="name"></p></div>

4
<div><p>Password <input type="password" name="password"></p></div>

<div> <input type="checkbox">I accept the terms and conditions</div><br>

<div> <input type="submit" name="signup"></div>

</form>

</body>

</html>

getph.php

<?php
$_GET['number'];
echo "Welcome get protocol";

?>

5
Output: -

Calling Get Protocol

6
Practical-2.b

Aim:- Create web form and page that properly use HTTP POST Protocol
Source code:-
Form.html
<html>

<head>

<title> post Protocol</title>

<style>

input[type=text]{

padding: 2px;

margin: 5px 0;

width: 30%

input[type=number]{

padding: 2px;

margin: 5px 0;

input[type=email]{

padding: 2px;

input[type=checkbox]{

margin: 5px 0;

input[type=date]{

padding: 2px;

7
margin: 5px 0;

</style>

</head>

<body>

<h1>Scholarship Form </h1>

<form action="post.php" method="post">

<div> Name <input type="text" name="name" ></div>

<div><p>Roll No<input type="number"></p></div>

<div> Father's name <input type="text" name="name"></div>

<div> Mother's name <input type="text" name="name"></div>

<div> Date of Birth <input type="date" name="date of birth"></div>

<div> College <input type="text" name="college"></div>

<div> Adhaar no. <input type="number" name="adhaar no."></div>

<div> Category <input type="radio" name="cat">SC <input type="radio" name="cat" >BC <input
type="radio" name="cat">OBC</div>

<div> Phone no. <input type="number" name="number"></div><br>

<div> DMC <input type="File"></div><br>

<div> Email <input type="email" name="email"></div>

<div> <input type="checkbox">I accept the terms and conditions</div><br>

<div> <input type="submit" name="signup"></div><br>

</form>

</body>
</html>

post.php
<?php
$_POST['number'];

echo"Welcome Post Protocol Of PHP"


?>

8
Output: -

Calling Post Protocol

CallingPostProtocol

9
Practical-3

Aim:- Design SQL language within MySQL and PHP to access and
manipulate database
Source code:-
<!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>MYSQL commands</title>
</head>
<body>
<h2>Creating Database in MYSQL</h2>
<?php
$servername="localhost";
$username="root";
$password="";
$sql="CREATE DATABASE Deepali3";
$conn=mysqli_connect($servername,$username,$password);
if(mysqli_query($conn,$sql)){
echo "<BR> Database created successfully";
}
else
{
echo "<BR> ERROR CREATING DATABASE:".MYSQLI_ERROR($CONN);

}
echo "<h2> creating table in database</h2>";
$dbname="Deepali3";
//create connection
$conn=mysqli_connect($servername,$username,$password,$dbname);
//check connection
if(!$conn){
die("connection failed:".mysqli_connect_error());
}
$sql="CREATE TABLE STUD3(NAME VARCHAR(30) NOT NULL, DEPT VARCHAR(30)
NOT NULL, ROLLNO INT(5))";

10
if(mysqli_query($conn,$sql)){
echo "<BR> table created successfully";
}
else{
echo "<BR>error creating table.mysqli_error($conn)";
}
//sql to insert row into table
$sql="INSERT INTO STUD3(NAME,DEPT,ROLLNO)VALUES('RAJAN','COMP',1)";
if(mysqli_query($conn,$sql)){
echo "<BR>row created successfully";
}
else{
echo "<BR>error".mysqli_error($conn);
}
//sql to insert row into table
$sql="INSERT INTO STUD3(NAME,DEPT,ROLLNO)VALUES('KAJAL','CIVIL',2)";
if(mysqli_query($conn,$sql)){
echo "<BR>row created successfully";
}
else{
echo "<BR>error".mysqli_error($conn);
}
$sql="INSERT INTO STUD3(NAME,DEPT,ROLLNO)VALUES('RAMAN','ECE',3)";
if(mysqli_query($conn,$sql)){
echo "<BR>row created successfully";
}
else{
echo "<BR>error".mysqli_error($conn);
}
//selecting the data from table
$sql="SELECT * FROM STUD3";
$result=mysqli_query($conn,$sql);
if(mysqli_num_rows($result)>0){
//output data of each row
echo "<table border='2'>";
echo"<tr><td>Student Name</td><td>Department</td><td>Roll
No</td></tr>";

while($row=mysqli_fetch_array($result)){
echo "<tr><br>";
echo "<td>" . $row['NAME'] . "</td>";
echo "<td>" . $row['DEPT'] . "</td>";
echo "<td>" . $row['ROLLNO'] . "</td>";
echo "</tr>";

11
}
echo "</table>";
}
else{
echo "0 results";
}
mysqli_close($conn);

?>
</body>
</html>

Output: -

12
Practical-4
AIM:- Install and configure both PHP and MYSQL
Installation On Windows
PHP on Window can work with Apache or IIS. Easy way to install Apache
and PHP: XAMPP server.
The acronym of XAMPP is Window, Apache, MYSQL, and PHP –which is
used to describe any window – based Wed server setup.
Follow These Steps, To Install XAMPP Server On Windows.
1. Open any web browser and
visit https://www.apachefriends.org/index.html. On the home
page, you can find the option to download XAMPP for three
platforms- Windows, MAC, and Linux. Click on XAMPP for
Windows. The latest version available on the website
is 7.4.5.
2. After the download is completed, double click the .exe
extension file to start the process of installation.

13
3. A pop-up screen with the message asking you to allow to

make changes on your desktop appears. Click "YES" to continue


the process.

14
4. Click to Allow access or deactivate the firewall and any other
antivirus software because it can hamper the process of
installation. Thus, it is required to temporarily disable any

antivirus software or security firewall till the time all the XAMPP.

5. Just before the installation, a pop-up window appears with a


warning to disable UAC. User Account Control (UAC) interrupts
the XAMPP installation because it restricts the access to write to
the C: drive. Therefore, it is suggested to disable it for the period
of installation.

15
6. After clicking the .exe extension file, the XAMPP setup wizard
opens spontaneously. Click on "NEXT" to start the configuration
of the settings.

16
7. After that, a 'Select Components' panel appears, which gives you
the liberty to choose amongst the separate components of the
XAMPP software stack for the installation. To get a complete
localhost server, it is recommended to install using the default
options of containing all available components. Click "NEXT" to
proceed further.

8. The setup is now ready to install, and a pop-up window


showing the same appears on the screen. Click "NEXT" to
take the process forward.

17
9. Select the location where the XAMPP software packet needs to
be installed. The original setup creates a folder titled XAMPP
under C:\ for you. After choosing a location, click "NEXT".

18
10. After choosing from all the previously mentioned
preferences (like language and learn more bitnami dialogue box)
click to start the installation. The setup wizard will unpack and
install the components to your system. The components are saved
to the assigned directory. This process may takes a few minutes
to complete. The progress of the installation in terms of
percentage is visible on the screen.

19
11. After the successful installation of the XAMPP setup on your
desktop, press the "FINISH" button.

20
On clicking the FINISH button, the software automatically launches,
and the CONTROL PANEL is visible. The image below shows the
appearance of the final result.

21
22
Practical-5
AIM:- Create PHP code that utilizes the commonly used API library
functions built in to PHP.
Source code:-
<?php
$day=date("l");
switch($day)
{
case"Sunday":
$var=$day;
break;
case"Monday":
$var=$day;
break;
case"Tuesday":
$var=$day;
break;
case"Wednesday"
:
$var=$day;
break;
case"Thursday":
$var=$day;
break;
case"Friday":
$var=$day;
break;
case"Saturday":
$var=$day;
break;
default:
print"Input is wrong";
}
echo"Today is".$var;
?>

23
Output: -

24
Practical-6
AIM:- Design and create a complete website that demonstrates good
PHP/MySQL client/serverdesign.
Home Page
Source Code:-
<!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>home page</title>
<style>
.abc:hover{
margin:30px 20px;
padding:12px 10px;
color:#4cc7c1;
}

</style>
</head>
<body>
<h1 align="center" class="abc"><marquee behavior=""
direction="">ONLINE BLOOD BANK </marquee></h1><br>
<center>
<div class="slideshow-container">
<div class="x fade">
<div class="numbertext">1 / 3</div>
<img
src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAOEAAADhCAMAAAAJbSJ
IAAABcVBMVEX////+T2AAAAD/S1z5+fn+TmL+T178//78T2Ltn6n9Rlv/8fPvRFTzbHz//

25
v/e3t6goKDp+ 0SnJLPmLmjUnWdVuAZQnAZDkFw3lERUC4h/DvKPeHdl3vCuy
/3hHdf7gnvvvz9Cf8fty5LMGQToOYAAAAASUVORK5CYII=" alt="No Internet">
</div>

<h3><a href="registeration.php">REGISTERATION OF DONOR</a>


<br>
<a href="view.php">VIEW OF DONOR</a>

</h3>
<br>
<h1>Welcome T Blood Bank</h1>
</body>
</html>
Registration Form
Source Code:-
<!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>Document</title>
</head>
<body>
<?php
if(isset($_POST['submit']))
{
$n=$_POST['name'];
$g=$_POST['gender'];
$d=$_POST['dob'];
$a=$_POST['age'];
$f=$_POST['fname'];
$l=$_POST['lname'];
$e=$_POST['email'];
$s=$_POST['state'];
$p=$_POST['pincode'];
$ad=$_POST['address'];
$c=$_POST['contact'];
$la=$_POST['landline'];
$bg=$_POST['bloodgroup'];
$servername="localhost";
$username="root";
$password="";

26
$dbname="blood";
//create connection
$conn=mysqli_connect($servername,$username,$password,$dbname);
//check connection
if(!$conn){
die("Connection failed:" . mysqli_connect_error());
}
$sql="insert into
donor(name,gender,dob,age,fname,lname,email,state,pincode,address,contact,landli
n e,bloodgroup)
values('$n','$g','$d',
'$a','$f','$l','$e','$s','$p','$ad','$c','$la','$bg')";
if(mysqli_query($conn,$sql)){
echo "<br>Row created successfully";

}
else{
echo "<br>Error" . mysqli_error($conn);
}
}
?>
<h1 align="center">ONLINE BLOOD BANK</h1><br>
<h1 align="center"><strong>DONOR REGISTERATION</strong></h1>
<form action="" method="POST">
<center>
<table width="60%">
<tr><td width="35%">
<label for="name">NAME OF THE DONOR</label>
</td>
<TD width="65%">
<input type="text" id="name" name="name" placeholder='enter name..'required>
</TD></tr>
<tr>
<td width="35%">
<label for="gender">Gender</label>
</td>
<td width="65%">
<select name=gender" id="gender">
<option value="Male">Male</option>
<option value="Female">Female</option>
<option value="Others">Others</option>
</select>
</td>
</tr>
<tr>

27
<td width="35%">
<label for="date of birth">DATE OF BIRTH</label>
</td>
<td width="65%">
<input type="date" id="date of birth" name="dob">
</td>
</tr>
<tr><td width="35%">
<label for="AGE">AGE</label>

</td>
<td width="65%">
<input type="number" id="age" name="age" placeholder='enter age...'>
</td></tr>
<tr>
<td width="35%">
<label for="fname">FATHER NAME</label>
</td>
<TD width="65%">
<input type="text" name="fname" id="fname" placeholder='enter your father
name'>

</TD>
</tr>

<tr>
<td width="35%">
<label for="lname">MOTHER NAME</label>
</td>
<TD width="65%">
<input type="text" name="lname" id="lname" placeholder='enter your mother
name'>

</TD>
</tr>
<tr>
<td width="35%">
<label for="email">EMAIL</label>
</td>
<td width="35%">
<input type="text" name="email" id="email" placeholder='@email'>
</td>
</tr>
<tr>
<td width="35%">

28
<label for="state">STATE</label>
</td>
<td width="35%">
<select name="state" id="state">
<option value="andra pradesh">Andra Pradesh</option>
<option value="arunachal pardesh">Arunachal Pardesh</option>
<option value="assam">Assam</option>
<option value="bihar">Bihar</option>
<option value="chhattisgarh">Chhattisgarh</option>
<option value="chandigarh">Chandigarh</option>
<option value="delhi">Delhi</option>
<option value="goa">Goa</option>
<option value="gujarat">Gujarat</option>
<option value="haryana">Haryana</option>
<option value="himachal pradesh">Himachal Pradesh</option>
<option value="jammu & kashmir">Jammu & Kashmir</option>
<option value="jharkhand">Jharkhand</option>
<option value="karnataka">Karnataka</option>
<option value="kerala">Kerala</option>
<option value="orissa">Orissa</option>
</select>
</td>
</tr>

<tr>
<td width="35%">
<label for="pincode">PINCODE</label>
</td>
<TD width="35%">
<input type="text" name="pincode" id="pincode" placeholder='PINCODE'>
</TD>
</tr>
<TR>
<TD width="35%">
<label for="address">ADDRESS</label>
</TD>
<td width="65%">
<input type="text" id="address" name="address" placeholder='ADDRESS'>
</td>
</TR>
<tr>
<td width="35%">
<label for="contact no">CONTACT NO</label>
</td>
<TD width="65%">

29
<input type="text" name="contact" id="contact no" placeholder='91+'>
</TD>
</tr>
<tr>
<td width="35%">
<label for="Landline">LANDLINE</label>
</td>
<td width="65%">
<input type="text" name="landline" id="landline" placeholder='LANDLINE'>
</td>
</tr>
<tr><td width="35%">
<label for="bloodgroup">BLOOD GROUP</label>

</td>
<TD width="35%">
<select name="bg" id="bloodgroup & RH.type">
<option value="A Positive">A Positive</option>
<option value="A Negative">A Negative</option>
<option value="B Positive">B Positive</option>
<option value="B Negative">B Negative</option>
<option value="O Positive">O Positive</option>
<option value="O Negative">O Negative</option>
<option value="A Positive">A Positive</option>

</select>
</TD>
</tr>

</table>
<input type="Submit" name="submit" value="Register">
</form>
<br>
<a href="home.php">HOME</a>

</body>

</html>

30
View.php
Source Code:-
<!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>Document</title>
</head>
<body>
<h1 align="center">ONLINE BLOOD BANK</h1>
<H1 align="center"><strong>VIEWING DONOR LIST</strong></H1>
<?php

$servername="localhost";
$username="root";
$password="";
$dbname="blood";
$conn=mysqli_connect($servername,$username,$password,$dbname);
if(!$conn){
die("connection failed:" . mysqli_connect_error());
}
$sql="insert into
donor(name,gender,dob,age,fname,lname,email,state,pincode,address,contact,landli
n e,bloodgroup) values('$n','$g','$d',
'$a','$f','$l','$e','$s','$p','$ad','$c','$la','$bg')";
$sql="select*from donor";
$result=mysqli_query($conn,$sql);
if(mysqli_num_rows($result)>0){
echo "<table border='2'";
echo "<tr><th>Donor Name</th><th>Gender</th><th>Date of
Birth</th><th>Age</th>
<th>Father's Name</th><th>Mother's Name</th>

31
<th>Email
ID</th><th>Address</th><th>State</th><th>Pincode</th><th>Contact</th><th>Land
line</th><th>Blood Group</th></tr>";
while($row=mysqli_fetch_assoc($result)){
echo "<tr>";
echo "<td>".$row['name']."</td>";
echo "<td>".$row['gender']."</td>";
echo "<td>".$row['dob']."</td>";
echo "<td>".$row['age']."</td>";
echo "<td>".$row['fname']."</td>";
echo "<td>".$row['lname']."</td>";
echo "<td>".$row['email']."</td>";
echo "<td>".$row['address']."</td>";
echo "<td>".$row['state']."</td>";
echo "<td>".$row['pincode']."</td>";
echo "<td>".$row['contact']."</td>";
echo "<td>".$row['landline']."</td>";
echo "<td>".$row['bloodgroup']."</td>";
echo "</tr>";
}
echo "</table>";

}
else{
echo "0 results";
}
mysqli_close($conn);
?>
<br>
<br>
<center>
<a href="home.php">HOME</a>

</body>
</html>

32
Output: -
Home Page

33
Registration Form

34
Practical 7

Aim:- To store a cookie using PHP on client side.

Source code:-
cc2.php
<!DOCTYPE html>
<?php
$cookie_name = "user";
$cookie_value = "Mukul";
setcookie($cookie_name, $cookie_value, time() + (86400 * 30), "/"); //
86400 = 1 day
?>
<html>
<body>

<?php
if(!isset($_COOKIE[$cookie_name])) {
echo "Cookie named '" . $cookie_name . "' is not set!";
} else {
echo "Cookie '" . $cookie_name . "' is set!<br>";
echo "Value is: " . $_COOKIE[$cookie_name];
}
?>

</body>
</html>

35
Output:-

36
Practical – 8

Aim:-To save the user session on server side.

Source Code:-

<?php
//Start the session
session_start();
?>
<!DOCTYPE html>
<html>
<body>
<?php
//Set sessiom variables
$_SESSION["favcolor"] ="red";
$_SESSION["favanimal"] ="rat";
echo"Session variable are set.";
//Printing session variables
echo "<br>Fav color " .$_SESSION["favcolor"];
echo "<br>Fav animal ".$_SESSION["favanimal"];
?>
</body>
</html>

37
Output:-

38
PRACTICAL-9

AIM- DESIGN WEBSITE USING WORDPRESS OR JOOMLA


To create web site in word press.

Open wordpress site on your computer in web browser by typing the


following URL i.e
www.wordpress.com and the following screen will appear on the
screen

39
Now click on start your website and the following screen will appear ,fill
the necessary information

40
Choose your goal

41
Give the domain name of your website

42
Choose the plan for your website

43
44
Click on page option in the side pane to create pages for website

Finally click on publish option to view the web site

45

You might also like