SHANKERSINH VAGHELA BAPU INSTITUTE OF TECHNOLOGY
Vasan, Gandhinagar
INFORMATION TECHNOLOGY DEPARTMENT
Affiliated to
GUJARAT TECHNOLOGICAL UNIVERSITY,Ahmadabad
Lab Manual for the subject
…....................................................................................
WEB PROGRAMMING
[Subject Code: 3160713]
…....................................................................................
B.E. – 3rd Year-2025
STUDENT NAME : Patil Viral Sureshbhai
ENROLLMENT. NO. : 230753107014
CLASS & BATCH : COMPUTER ENGINEERING
ACADEMIC TERM : 2025
Certificate
This is to certify that Mr. Patil Viral S. Enrollment No.230753107014 of
B.E. COMPUTER ENGINEERING Semester 6th has Satisfactorily
completed his/her term work in subject name Web Programming bearing
the subject code 3160713 as per Gujarat Technological University of the
Laboratory / Drawing Hall of this College during the academic term from
date 21/1/2025 to date 10/5/2025.
Place: Vasan
Date:
Subject Teacher Head of the Department
Prof. Janvi Patel Prof. Priyanka Patel
Index
Sr. List of Practical Date Page Sign
Practical 01 (HTML)
1 Write HTML Code for given list.
2 Write a HTML program to draw table shown below.
3 Write a HTML program for given form.
4 Write HTML code for given frames
Practical 02 (CSS)
1 Write a CSS that sets an element to occupy 60% of
the screen width and that is centered horizontally.
2 Write an Internal CSS with following rules.
3 Write the following styles in separate CSS file and
also show how to link this CSS file in HTML file
and show use of styles.
4 Write a HTML program to draw table shown
below.
Also write CSS rules so that
Practical 03 (JavaScript)
1 Write a JavaScript program using object to find
the area of circle, rectangle and triangle.
2 Write a JavaScript program to perform form
validation.
3 Write a JavaScript to display person detail using
object.
4 Write a JavaScript to find first 10 prime numbers.
5 Write a JavaScript to check input string is
palindrome or not.
Practical 04 (PHP)
1 Write a PHP program to check whether given number
is odd or even.
2 Write a PHP program to find largest numbers among
three numbers.
3 Write a PHP program to make the sum of first 100
odd numbers.
4 Write a PHP program to find whether entered year is
leap year or not.
5 Write a PHP program to print Fibonacci series (0 1 1 2
35
8...).
6 Write PHP and HTML page to get the reverse of
entered string in textbox when button is clicked.
7 Write a PHP program to enter registration detail for
student and display it into table format to the next
page.
8 Create MySQL database and table; insert, retrieve
data from table.
Update student record based on enrollment number of
the student. (enter number from textbox)
Delete student record based on enrollment number of
the student. (enter number from textbox).
Practical:01(HTML)
Aim 1:Write HTML Code for given list.
Code:
<html>
<head>
<title> Write HTML Code for given list. </title>
</head>
<body>
<ul type="circle">
<li> Chapter-1 Web Design </li>
<ul type="square">
<li> Web Site structure </li>
<li> Web design planning </li>
</ul>
<li> Chapter-2 HTML </li>
<ul type="square">
<li> HTML tag </li>
<li> List </li>
</ul>
<ol>
<ul type="disc">
<li> ordered list </li>
<ul type="none">
<li> - arrange items in order </li>
</ul>
<li> Unordered list </li>
<ul type="none">
1
<li> - arrange items without order </li>
2
</ul>
</ol>
<li> Chapter-3 CSS </li>
<ol type="1">
<li> Inline Stylesheet </li>
<li> External Stylesheet </li>
</ol>
</ul>
</body>
</html>
Output:-
3
Aim 2: Write a HTML program to draw table shown below.
1. table background is of RED color.
2. Cell data is center aligned.
Code:
<html>
<head>
<title> Table Practical </title>
</head>
<body>
<center>
<table border="1" width=50% height=20% bgcolor="red">
<tr>
<td colspan=4 align="center"> A </td>
</tr>
<tr>
<td rowspan=2 align="center"> B </td>
<td colspan=2 align="center"> C </td>
<td align="center"> D </td>
4
</tr>
<tr>
<td align="center"> E </td>
<td align="center"> F </td>
<td align="center"> G </td>
</tr>
<tr>
<td align="center"> H </td>
<td align="center"> I </td>
<td colspan=2 align="center"> J </td>
</tr>
</table>
</body>
</html>
Output:-
5
Aim 3: Write a HTML program for given form.
Code:
<html>
<head>
<title> Registration form </title>
</head>
<body>
<center>
<h1> My feedback form </h1>
<form name="Home Page" action="submit.php" method="post">
<ul type="disc">
<li> Name: <input type="text" name="txtname" value=""></li>
<li> Email: <input type="text" name="txtemail" value=""></li>
<li> Password: <input type="Password" name="txtname" value=""></li>
<li> Please Check all the emotions that apply to you: </li>
<ul type="disc">
<li> Angry <input type="checkbox" name="emotion" value="Angry"></li>
<li> Sad <input type="checkbox" name="emotion" value="Sad"></li>
<li> Happy <input type="checkbox" name="emotion" value="Happy"></li>
<li> Ambivalent <input type="checkbox" name="emotion"
value="Ambivalent"></li>
</ul>
<li> How Satisfied were you with our Service? </li>
<ul type="disc">
<li> Very Satisfied <input type="Radio" name="Service" value="Very
Satisfied"></li>
<li> Satisfied <input type="Radio" name="Service" value="Satisfied"></li>
<li> Don't care <input type="Radio" name="Service" value="Don't care"></li>
<li> Dissatisfied <input type="Radio" name="Service" value="Dissatisfied"></li>
</ul>
<li> Further Comments: <textarea row=5 cols=25 name="Comments"
value=""></textarea></li>
6
<li> Bio Photo <input type="File" name="biophoto" value="biopic"></li>
<li> Location Visited:
<select name="Dropdown" multiple>
<option Selected> Select Location </option>
<option> Mansa </option>
<option> Gandhinagar </option>
<option> Vadodara </option>
<option> Surat </option>
<option> Mehsana </option>
<option> Goa </option>
</li>
</select>
<br>
<li><input type="Submit" Vaule="Submit"></li>
</ul>
</form>
</body>
</html>
7
Output:-
8
Aim 4: Write HTML code for given frames.
Code:
Frame1.html Frame2.html
Frame3.html Frame4.html
9
FinalOutput.html
Output:-
10
Practical:02(CSS)
Aim 1:Write a CSS that sets an element to occupy 60% of the
screen width and that is centered horizontally.
Code:
<!DOCTYPE html>
<html>
<head>
<style><!—Internal CSS Use -->
p{
text-align: center;
width:60%;
}
</style>
</head>
<body><!—Element Selector Use -->
<p> Element to occupy 60% of the screen width and
that iscentered horizontally.</p>
</body>
</html>
Output:-
11
Aim 2:Write an Internal CSS with following rules.
i) Paragraph with font-family times new roman, size 150%.
ii) Text capitalized abd underline with indent of 1 cm.
iii) Make its use in body part of your sample html page.
Code:
<html>
<head>
<title> Inline CSS Practical </title><!—Inline CSS Use -->
</head>
<body>
<p style="font-size:150%;"> This Font Size 150% </p>
<h1 style="text-transform:capitalize;"> this is capitalize </h1>
<h2 style="text-decoration:underline;text-indent:1cm;"> Text Decoration:-
Underline and Text Indent 1cm </h2>
<p style="font-family:Times New Roman";> Font-Family : Times New Roman
</p>
</body>
</html>
Output:-
12
Aim 3:Write the following styles in separate CSS file and also show
how to link this CSS filein HTML file and show use of styles.
(i) The headings should have normal font style and font’s size
should be 120%
(ii) Define a class arial for paragraph which defines font
family arial and font style bold.
(iii) Apply a background color yellow and apply a
background image “browntile.jpg”.
Code:
ExternalCssFile.css
13
ExternalCss.html
Output:-
14
Aim 4:Write a HTML program to draw table shown below.
Also write CSS rules so that
1. table background is of RED color
2. Cell data is center aligned.
Code:
<html>
<head>
<title> Css Table </title>
<style>
td {
background-color: red;
text-align: center;
}
</style>
</head>
<body>
<table border="1" width="50%" height="20%">
<tr>
<td> A </td>
<td> B </td>
<td> C </td>
<td rowspan="3"> D </td>
</tr>
<tr>
15
<td> E </td>
<td colspan="2"> F </td>
</tr>
<tr>
<td> G </td>
<td> H </td>
<td> I </td>
</tr>
</table>
</body>
</html>
Output: -
16
Practical:03 (JavaScript)
Aim 1:Write a JavaScript program using object to find the area of
circle, rectangle and triangle.
Code:
<!DOCTYPE html>
<html>
<head>
<title>JavaScript Practical </title>
<script>
function calcutionpart()
{
var redius=document.form1.textredius.value;
var Length=document.form1.textlength.value;
var Width=document.form1.textwidth.value;
var Height=document.form1.textheight.value;
document.write("<p> Area of Sqaure:"+(Length*Length)+"</p>" );
document.write("<p> Area of Rectangle:"+(Length*Width)+"</p>" );
document.write("<p> Area of Triangle:"+(0.5*Height*Length)+"</p>" );
document.write("<p> Area of Circle:"+(redius*redius*Math.PI)+"</p>" );
}
</script>
</head>
<body>
<form name=form1>
<center>
<p> Area of Shape </p>
<ul>
<li>Redius <input type="txt" name=textredius value=""></li>
<li>Length <input type="txt" name=textlength value=""></li>
17
<li>width <input type="txt" name=textwidth value=""></li>
<li>Height <input type="txt" name=textheight value=""></li>
<ul>
<li><input type="button" name="Calculate" value="Calculation"
onclick="calcutionpart()"></li>
</ul>
</ul>
</center>
</form>
</body>
</html>
18
Output:
19
Aim 2:Write a JavaScript program to perform form validation.
Code:
<!DOCTYPE html>
<html>
<head>
<title> Validate Form </title>
</head>
<body>
<script>
function validatedemo()
{
var name = document.myform.txtname.value;
var password = document.myform.txtpassword.value;
if (name==null || name=="")
{alert("Please Enter the Name");
return false;
}
else if (password.length<6)
{
alert("Please Valid Password");
return false;
}}</script>
<form name="myform" method="post" action="www.w3school.com">
Name <input type="text" name="txtname"><br>
Password <input type="password" name="txtpassword"><br>
<input type="submit" name="submit" value="Submit" onclick="validatedemo()">
</form>
</body>
</html>
20
Output:
21
Aim 3:Write a JavaScript to display person detail using object.
Code:
<!DOCTYPE html>
<html>
<head>
<title> Detail </title>
<p id="demo"></p>
<script>
var
person=
{name:"Raj",lastname:"Patel",DOB:"20/09/2001",Age:20,Enrollment:"190750107
028"}
document.getElementById("demo").innerHTML="First Name:
"+person.name+"<br>"+"Lastname:"+person.lastname+"<br>"+
"Age:"+person.Age+"<br>"+"DOB:"+person.DOB+"<br>"+"Enrollment
no:"+person.Enrollment;
</script>
</head>
<body>
</body>
</html>
22
Output:
23
Aim 4:Write a JavaScript to find first 10 prime numbers.
Code:
<html>
<head>
<title>Prime Number</title>
<script>
function printPrime()
{
var i=0;
var j=0;
limit=document.getElementById("limit").value;
for(i=1;i<=limit;i++)
{
c=0;
for(j=1;j<=i;j++)
{
if(i%j==0)
{
c++;
}
}
if(c==2)
{
document.getElementById("result").insertAdjacentHTML('beforeend',i+'<br>');
}
}
}
</script>
</head>
<body>
24
<h2>Print Prime Numbers</h2>
Enter the limits: <input type="number" name="limit" id="limit" min="0"/> 
<input type="submit" value="Print Prime Numbers" onclick="printPrime()">
<div id="result"></div>
</body>
</html>
Output:
25
Aim 5:Write a JavaScript to check input string is palindrome or not.
Code:
<!DOCTYPE html>
<html>
<title>Javascript</title>
<script type="text/javascript">
function checkPalindrome(){
var isPalindrome = true;
var result = document.getElementById("result");
var strElement = document.getElementById("getstr");
if (strElement!=null){
let str = strElement.value ;
var strLength = str.length;
var mid = strLength/2;
for (let i=0;i<mid;i++){
if (str.charAt(i)!=str.charAt(str.length-i-1)){
isPalindrome = false;
break;
}
}
if (isPalindrome){
26
result.innerHTML = "String " +str+ " is a Palindrome String";
}
else{
result.innerHTML = "String " +str+ " is not Palindrome String";
}
}
}
</script>
<body>
<h3>Javascript Program to Check String Palindrome</h3>
<span>Enter the String</span>
<input type="text" name="getstr" id="getstr" value="">
<button onclick="checkPalindrome()">Check Palindrome</button>
<div id="result"></div>
</body>
</html>
Output:
27
Practical:03 (PHP)
Aim 1:Write a PHP program to check whether given number is odd
or even.
Code:
<html>
<head>
<title> Odd Even Practical </title>
</head>
<body>
<form method="post">
Enter a number: <input type="number" name="number" value="">
<br>
<input type="submit" value="Submit">
</form>
</body>
</html>
<?php
if($_POST){
$number=$_POST['number'];
if(($number%2)==0)
{
echo "$number is an Even number";
}
28
else
{
echo "$number is an Odd number";
}}
?>
Output:-
29
Aim 2:Write a PHP program to find largest numbers among
three numbers.
Code:
<html>
<head>
<title> Find Largest Numbers </title>
</head>
<body>
<form method="post">
A: <input type="number" name="num1" value=""><br>
B: <input type="number" name="num2" value=""><br>
C: <input type="number" name="num3" value=""><br>
<input type="submit" value="Find">
</form>
</body>
</html>
<?php
if($_POST)
{
$a = $_POST["num1"];
$b = $_POST["num2"];
$c = $_POST["num3"];
if($a>$b && $a>$c)
{
echo "Greater Value A = ".$a;
30
}
else if($b>$a && $b>$c)
{
echo "Greater Value B = ".$b;
}
else if($c>$a && $c>$b)
{
echo "Greater Value C = ".$c;
}
else
{
echo " All Number are Equal ";
}}
?>
Output:
31
Aim 3:Write a PHP program to make the sum of first 100 odd
numbers.
Code:
<html>
<head>
<title> Find Largest Numbers </title>
</head>
<body>
<form method="post">
Enter Number: <input type="number" name="num" value=""><br>
<input type="submit" value="Calculate">
</form>
</body>
</html>
<?php
$sum_odd = 0;
$counter = 0;
if($_POST)
{
$number = $_POST["num"];
for($i=0;$counter<$number;$i++)
{
32
if($i%2==0)
{
$sum_even+=$i;
}
else
{
$sum_odd += $i;
$counter++;
}
}
}
echo "Your Answer is : ".$sum_odd;
?>
Output:
33
Aim 4:Write a PHP program to find whether entered year is leap
year or not.
Code:
<html>
<head>
<title> Leap Year Program </title>
</head>
<body>
<form method="post">
Enter Number: <input type="number" name="num" value=""><br>
<input type="submit" value="Calculate">
</form>
</body>
</html>
<?php if($_POST)
{
$number = $_POST["num"];
if($number%400==0)
{
echo "$number is the Leap Year";
}
else if($number%100==0)
34
{
echo "$number not a Leap Year";
}
else if($number%4==0)
{
echo "$number is the Leap Year";
}
else
{
echo "$number not a Leap Year";
}
}
?>
Output:
35
Aim 5:Write a PHP program to print fibonacci series (0 1 1 2 3 5..).
Code:
<html>
<head>
<title> Fibonacci Series Program </title>
</head>
<body>
<h2> Fibonacci Series Program </h2>
<form method="post">
Enter Number: <input type="number" name="num" value=""><br>
<input type="submit" value="Calculate">
</form>
</body>
36
</html>
<?php
if($_POST)
{
$number = $_POST["num"];
function recursive($number)
{
if($number==0)
{
return 0;
}
else if($number==1)
{
return 1;
}
else
{
return (recursive($number-1)+recursive($number-2));
}
}
for ($i=0;$i<$number;$i++)
echo recursive($i)." ";
}
?>
Output:
37
Aim 6:Write PHP and HTML page to get the reverse of entered
string in textbox when button is clicked.
Code:
<html>
<head>
<title> Reverse String </title>
</head>
<body>
<form method="post">
Enter Number: <input type="text" name="txt" value=""><br>
<input type="submit" value="Click Now">
</form>
</body>
</html>
<?php
if($_POST)
{
$str = $_POST["txt"];
echo "Reverse String of $str is ".strrev($str);
}
?>
Output:
38
Aim 7:Write a PHP program to enter registration detail for student
and display it into table format to the next page.
Registration Form
Code:
<!DOCTYPE html>
<html>
<head>
<title> Registration Form </title>
<style>
table
{
text-align: center;
}
</style>
</head>
39
<body>
<center>
<h1> Registration Form </h1>
<form method="POST" action="data.php">
<table border="1">
<tr>
<td> Enter your Name </td>
<td><input type="text" name="txtname"
</tr>
required=""></td>
<tr>
</tr>
<tr> <td> Enter your Email </td>
<td><input type="email" name="txtemail" required
=""></td>
<td> Enter your Password </td>
<td><input type="Password" name="txtpassword" required =""
minlength="6"></td>
</tr>
<tr>
<td> Enter your Address </td>
<td><textarea row=5 cols=20 name="address" required =""></textarea></td>
</tr>
<tr>
<td> Enter your Mobile number </td>
<td><input type="number" name="num" value="" minlength="10"></td>
</tr>
</tr>
<tr>
40
required=""></td> <td> Enter your Enrollment no </td>
</tr> <td><input type="number" name="enrollment"
<tr>
<td> Select your Gender </td>
value="Female"> <td> Male <input type="radio"
name="Gender" value="Male"> Female
<input type="radio" name="Gender"
Transgender <input type="radio"
name="Gender"
value="Transgender">
</td>
</tr>
<tr >
<td colspan="2" align="center">
<input type="Submit" name="submit" value="Registration
Me">    <input type="reset" value="Reset"></td>
</tr>
</table>
</form>
</center>
</body>
</html>
41
Output:
42
Display Data
<!DOCTYPE html>
<html>
<head>
<title> Database </title>
</head>
<body>
<?php
if(isset($_POST['submit']))
{
$name = $_POST['txtname'];
$email =$_POST['txtemail'];
$password =$_POST['txtpassword'];
$address =$_POST['address'];
$mobile =$_POST['num'];
$enrollment =$_POST['enrollment'];
$gender =$_POST['Gender'];
echo "<center><h2><u>Display Data</u></h2>";
echo "<table border='1' cellspacing='0' cellpadding='5'>";
echo "<tr><td>Student Name</td><td>";
echo $name."</td></tr>";
echo "<tr><td>Email id</td><td>";
echo $email."</td></tr>";
echo "<tr><td>PassWord</td><td>";
echo $password."</td></tr>";
echo "<tr><td>Address</td><td>";
echo $address."</td></tr>";
43
echo "<tr><td>Mobile number </td><td>";
echo $mobile."</td></tr>";
echo "<tr><td>Enrollment number </td><td>";
echo $enrollment."</td></tr>";
echo "<tr><td> Gender </td><td>";
echo $gender."</td></tr>";
echo "</table></center>";
}
?>
</body>
</html>
Output:
44
Aim 8:create MySQL database and table; insert, retrieve data from
table.
● Update student record based on enrollment number of the
student. (enter number from textbox).
● Delete student record based on enrollment number of the
student. (enter number from textbox).
Code:
Create MySQL database and table; insert, retrieve data from table.
Creatdb.php
<!DOCTYPE html>
<html>
<head>
<title>Create Database</title>
</head>
<body>
<?php
$servername='localhost';
$username='root';
$password='';
$C = mysqli_connect($servername,$username,$password);
if(! $C)
{
die('Could not connect:'.mysql_error());
45
}
echo "Connected Successfully";
$sql='CREATE Database mykt';
$a=mysqli_query($C,$sql);
if(! $a){
die('Could not create Database:'.mysqli_error());
}
echo "Database test created successfully";
mysqli_close($C);
?>
</body>
Output:
46
Createtable.php
<!DOCTYPE html>
<html>
<head>
<title>CreateingMysql Table</title>
</head>
<body>
$servername='localhost';
<?php
$username='root';
$password='';
$C mysqli_connect($servername,
$username,$password);
if(! $C){
die('Connection failed:'.mysqli_error());
}
//echo "Connected Successfully";
$sql="CREATE TABLE createtable(eno INT(6),
firstnameVARCHAR(30)NOT NULL,
lastnameVARCHAR(30)NOT NULL,
email VARCHAR(50),
branch VARCHAR(50))";
mysqli_select_db($C,'mydbkt');
47
$q=mysqli_query($C,$sql);
if($q){
echo "Table created Successfully";
}
else{
echo"Error creating table:".mysqli_error($C);
}
mysqli_close($C);
?></body>
</html>
Output:
48
Insert and Retrieve Data:-
Registration.html
<!DOCTYPE html>
<html>
<head>
<title>Registration Form</title>
</head>
<body>
<center>
<h2><u>Registration Form</u></h2>
<form method="POST" action="p1.php">
<table width="50%" border="1" cellspacing="0" cellpadding="5">
<tr>
<td>Enter Name:</td>
<td><input type="text" placeholder="Enter Name" name="name"
required=""></td>
</tr>
<tr>
<td>Enter E-mail:</td>
<td><input type="email" placeholder="Enter E-mail" name="email"
required=""></td>
</tr>
<tr>
49
<td>Enter Enrollment:</td>
<td><input type="number" placeholder="Enter Enrollment"
name="enrollment" required=""></td>
</tr>
<tr>
<td>Enter Password:</td>
<td><input type="Password" placeholder="Enter Password" name="pwd"
required=""></td>
</tr>
<tr>
<td>Enter Address:</td>
<td><textarea name="address" placeholder="Enter
Address"></textarea></td>
</tr>
<tr>
<td>Select Gender</td>
<td>
Male<input type="radio" name="gender" value="male">
Female<input type="radio" name="gender" value="female">
</td>
</tr>
<tr>
<td colspan="2" align="center">
<input type="submit" name="submit" value="register me">
<input type="reset" value="Reset">
50
</table>
</form>
</center>
</body>
</html>
p1.php
<html>
<head>
<title>Display Data</title>
</head>
<body>
<?php
if(isset($_POST['submit']))
{
$name=$_POST['name'];
$email=$_POST['email'];
$enrollment=$_POST['enrollment'];
$pwd=$_POST['pwd'];
$add=$_POST['address'];
$gen=$_POST['gender'];
echo "<center><h2><u>Display Data</u></h2>";
echo "<table border='1' cellspacing='0' cellpadding='5'>";
echo "<tr><td>Student Name:</td><td>";
51
echo $name."</td></tr>";
echo "<tr><td>Student E-
mail:</td><td>"; echo
$email."</td></tr>";
echo "<tr><td>Student
Enrollment:</td><td>"; echo
$enrollment."</td></tr>";
echo "<tr><td>Student
Password:</td><td>"; echo
$pwd."</td></tr>";
echo "<tr><td>Student
Address:</td><td>"; echo
$add."</td></tr>";
echo
"<tr><td>Gender:
</td><td>"; echo
$gen."</td></tr>";
echo "</td></tr>";
echo "</table></center>";
}?></body></html>
52
Output:
53
Update And Delete:-
Index.php
<?php
include 'all_process.php';
if (isset($_GET['edit'])) {
$id = $_GET['edit'];
$edit_state = true;
$record = mysqli_query($conn, "SELECT * FROM php WHERE id=$id");
$data = mysqli_fetch_array($record);
$name = $data['name'];
$email = $data['email'];
$enrollment = $data['enrollment'];
$password = $data['password'];
$address = $data['address'];
54
}
?>
<!DOCTYPE html>
<html>
<head>
<link rel="stylesheet" type="text/css" href="style.css">
<title>Registration form</title>
</head>
<body>
<center>
<?php if (isset($_SESSION['message'])):?>
<div class="message">
<?php
echo $_SESSION['message'];
unset($_SESSION['message']);
?>
</div>
<?phpendif ?>
<h1>Update and Delete</h1>
<form class="form-inline" method="POST" action="all_process.php">
<input type="hidden" name="id" value="<?php echo $id; ?>">
<input type="text" name="name" placeholder="Name" value="<?php echo $name;
?>">
<input type="email" name="email" placeholder="Email" value="<?php echo
$email; ?>">
55
<input type="text" name="enrollment" placeholder="Enrollment" value="<?php
echo $enrollment; ?>">
<input type="password" name="password" placeholder="password" value="<?php
echo $password; ?>">
<input type="text" name="address" placeholder="address" value="<?php echo
$address; ?>">
<?php if ($edit_state == false): ?>
<button class="btn" type="submit" name="save" >Save</button>
<?php else: ?>
<button class="btn" type="submit" name="update" >Update</button>
<?phpendif ?>
</form>
<table>
<tr>
<th>Sr No</th>
<th>Name</th>
<th>Email</th>
<th>Enrollment</th>
<th>Password</th>
<th>Address</th>
<th>Action</th>
</tr>
<?php
56
$result = mysqli_query($conn, "SELECT * FROM php");
$i = 1;
while ($row = mysqli_fetch_assoc($result)) {
?>
<tr>
<td><?php echo $i; ?></td>
<td><?php echo $row["name"]; ?></td>
<td><?php echo $row["email"]; ?></td>
<td><?php echo $row["enrollment"]; ?></td>
<td><?php echo $row["password"]; ?></td>
<td><?php echo $row["address"]; ?></td>
<td><a href="index.php?edit=<?php echo $row["id"]; ?>"
class="edit_btn">Edit</a></td>
<td><a href="all_process.php?delete=<?php echo $row["id"]; ?>"
class="del_btn">Delete</a></td>
</tr>
<?php
$i++;
}
?>
</table>
</center>
</body>
</html>
57
all_process.php
<?php
session_start()
;
include_once 'connect.php';
$name = "";
$email = "";
$enrollment = "";
$password = "";
$address = "";
$id = 0;
$edit_state = false;
if (isset($_POST['save'])) {
$name = $_POST['name'];
$email = $_POST['email'];
$enrollment = $_POST['enrollment'];
$password = $_POST['password'];
$address = $_POST['address'];
$sql = "INSERT INTO php (name,email,enrollment,password,address) VALUES
('$name','$email','$enrollment','$password','$address')";
if (mysqli_query($conn, $sql)) {
$_SESSION['message'] = "Data Saved Successfully";
header("Location: index.php");
58
}
else { mysqli_close($conn);}
}
// For updating records
if (isset($_POST['update'])) {
$id = $_POST['id'];
$name = $_POST['name'];
$email = $_POST['email'];
$enrollment = $_POST['enrollment'];
$password = $_POST['password'];
$address = $_POST['address'];
mysqli_query($conn, "UPDATE php SET
name='$name',email='$email',enrollment='$enrollment',password='$password',
address='$address' WHERE id=$id");
$_SESSION['message'] = "Data Updated Successfully";
header('location: index.php');
}
// For deleteing records
if (isset($_GET['delete'])) {
$id = $_GET['delete'];
mysqli_query($conn, "DELETE FROM php WHERE id=$id");
$_SESSION['message'] = "Data Deleted Successfully";
header('location:index.php');
}?>
59
Output:
60
Update Using Enrollment:
61
62
Delete using Enrollment:
63