0% found this document useful (0 votes)
28 views103 pages

Awad New Manual

The document is a lab manual for the Advanced Web Application Development course at Chaitanya Bharathi Institute of Technology, detailing course objectives, outcomes, and a comprehensive syllabus. It covers various modules including PHP basics, database connectivity, web application security, and hosting services, with practical tasks for students to complete. The manual also outlines general instructions for lab work and includes references and resources for further learning.

Uploaded by

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

Awad New Manual

The document is a lab manual for the Advanced Web Application Development course at Chaitanya Bharathi Institute of Technology, detailing course objectives, outcomes, and a comprehensive syllabus. It covers various modules including PHP basics, database connectivity, web application security, and hosting services, with practical tasks for students to complete. The manual also outlines general instructions for lab work and includes references and resources for further learning.

Uploaded by

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

CBIT–B.

Tech(R22)–CSE

CHAITANYA BHARATHI INSTITUTE OF TECHNOLOGY


(An Autonomous College under JNTUA, Anantapuramu, Approved by
AICTE, Accredited by NBA, Accredited by NAAC with ‘A’ Grade)
VidyaNagar, Pallavolu (V), Proddatur–516362(A.P)India

Department of ComputerScience& Engineering

Third Year B.Tech


Advanced Web Application Development(20A05506)
Lab Manual under R20 Regulations

Prepared by: Approved by:


R.Abdul Hussain Dr. Y. Dasarada Rami Reddy
Assistant Professor Assoc. Professor
Department of CSE Head of the Department CSE

Academic Year:2024-2025

1
CBIT–B.Tech(R22)–CSE

CHAITANYA BHARATHI INSTITUTE OF TECHNOLOGY


(An Autonomous College under JNTUA, Anantapuramu, Approved by AICTE,
Accredited by NBA, Accredited by NAAC with ‘A’ Grade)
VidyaNagar, Pallavolu(v), Proddatur-516362(A.P) India
(20A05506)ADVANCED WEB APPLICATION DEVELOPMENT LAB

Course Credits
Category: Professional Core 1.5
Course Type: Lab Lecture-Tutorial-Practice: 0-0-3
Prerequisites: MySQL Continuous Evaluation: 30
YEAR& IIIB.TECH-I SEM Semester end Evaluation: 70
PROGRAMME CSE
Total Marks 100
Course • Learn how to create dynamic websites using PHP and establish database connectivity.
objectives • Explore SMS API and session management
• Understand the common Web Application Vulnerabilities and provide Security.
• Acquire the knowledge of external libraries to generate various types of documents
and files.
• Understand the difference between traditional hosting services and Cloud Hosting
service
Course After completion of the course, students will be able to
Outcomes CO1 Create dynamic websites using PHP and MySQL
CO2 Handle Authentication using Sessions, JWT.
CO3 Secure Web applications from common attacks like Injection, XSS

CO4 Integrate Libraries to dynamically generate documents, spreadsheets, pdfs,


etc
CO5 Host Websites in traditional web hosting platforms and also Cloud based
infrastructure
Course Content DETAILED SYLLABUS:
Module 1:
Introduction: Web Server, Database Server, Private IP Address, Port Address, Server-
side Programming, Web Server solution stack.
Task: Installation of XAMPP/WAMP. Access a test page using a device
(Laptop/Desktop/Mobile) within LAN or hotspot using its private IP address.
Module 2:
PHPMyAdmin: Create, Browse, Drop, Copy, Rename and Alter databases, tables,
views, fields and indexes, Import data from CSV and SQL, Export (back-up) data.
Task: Design a Student Profile Data Management System for a college. Create a
Database and its associated tables.

Module 3:
Php basics: Basic Syntax, primitive types, Variables, Constants, Expressions,
Operators, Control structures, functions.
Task: Develop a PHP application and run it with a command-line interpreter

2
CBIT–B.Tech(R22)–CSE

Module 4:
Handling HTML Forms: Predefined Variables, Reading data from web form controls
like input, textarea, select etc., Handling File Uploads.
Task: Develop an Add Student Profile Page which accepts all student details including
photo and display them in order.

Module 5:
Predefined Functions and Files: Arrays, Associative Arrays, Multidimensional Arrays,
Array functions, String functions, Date and Time functions, File Handling: Open, Close,
Create, Read, Write, Append.
Task: Implement an effective Logging System using files in PHP.

Module 6:
Classes and Objects: Creating classes and objects, Visibility, Constructor and
Destructor, Inheritance, static keyword, interfaces, class Abstraction, namespaces
Task: Design and implement Class diagram representation of Student Management
System for a college using PHP.

Module 7:
Database Connectivity with MySql: Establish a database Connection using mysqli,
Prepare SQL Statement, Bind parameters, Execute the statement, bind the result.
Task: Develop Add Student Profile Page to store data into the database and develop a
webpage to retrieve the student details based on the Roll Number or any unique ID.

Module 8:
HTTP is a Stateless Protocol: Handling Cookies and Sessions, Implementation of JSON
Web Tokens (JWT), SMS API.
Task: Design and develop a User Authentication System (Login-Logout functionality)
using cookies, sessions, JWT, and SMS API. Also, identify which is suitable for your
application

Module 9:
Exception Handling and Security: Handle Database connectivity exceptions, SQL
Injection Vulnerability, Cross-site scripting, Session hijacking, and Session fixation
Task: Secure all your PHP applications from common vulnerabilities like Injection, XSS,
Session hijacking and fixation, and other exceptions

Module 10:
PHP Libraries: Read data from Excel Files, Generate dynamic Excel Files, PDF files, and
Word Documents.
Task: Design an Administrator Portal through which administrators can be able to
upload student data into the database, Download the student data, Generate
certificates, etc.

Module 11:
Hosting service provider: Public IP Address, Nameservers, Domain Name, Understand
cPanel Modules: File Manager, Databases, Email Accounts, One-Click Installers, DNS,
Other Configuration & Monitoring Controls.
Task: Host a PHP-MySQL based application on the internet using the Web Hosting

3
CBIT–B.Tech(R22)–CSE
Service Provider of your choice (000webhost, Hostinger, Heroku, Godaddy, etc.)

Module 12:
Cloud Hosting: Advantages of Cloud Hosting, Creating Instances or droplets,
Managing Roles, Scaling the Application, Securing the instances, Monitoring Tools,
etc.
Task: Host a PHP-MySQL based application on the internet using the Cloud Hosting
Provider of your choice (Amazon Web Services, Google Cloud Platform, DigitalOcean,
etc.)

Text Books and REFERENCE BOOKS:


Reference books 1. MacIntyre, Peter, and Tatroe, Kevin. Programming PHP: Creating Dynamic Web Pages.
United States, O'Reilly Media, 2020.
2. Valade, Janet. PHP and MySQL Web Development All-in-One Desk Reference For
Dummies. Germany, Wiley, 2011.
3. Gulabani, Sunil. Amazon Web Services Bootcamp: Develop a Scalable, Reliable, and
Highly.
E-Resources and 1. https://www.apachefriends.org/
other digital 2. https://www.wampserver.com/en/
materials 3. https://www.php.net/
4. https://in.godaddy.com/
5. https://www.hostinger.in/
6. https://aws.amazon.com/
7. https://cloud.google.com/

4
CBIT–B.Tech(R22)–CSE

CHAITANYA BHARATHI INSTITUTE OF TECHNOLOGY


(An Autonomous College under JNTUA, Anantapuramu,
Approved by AICTE, Accredited by NBA, Accredited by
NAAC with ‘A’ Grade)
VidyaNagar, Pallavolu (V), Proddatur–516362(A.P)India

ADVANCED WEB APPLICATION DEVELOPMENT


(20A05506)

VISION & MISSION

To develop into a Centre of Excellence for education and research in


Vision Computer Science and Engineering.
• To establish various emerging hardware and software platforms.
• To engage with industries and research organizations for solving real
world problems with social awareness.
Mission • To Promote Quality education and ethics among the students.

PROGRAM EDUCATIONAL OBJECTIVES

PEO PEO
No. Description

PEO 1 Graduates of Computer Science and Engineering will apply contemporary


technologies in computer science and engineering to develop solutions for
realistic and social issues.

PEO 2 Graduates of Computer Science and Engineering will have successful career
in software and hardware industries or pursue higher studies/research or
become entrepreneurs.

PEO 3 Graduates of Computer Science and Engineering will exhibit teamwork, good
communication skills and ethical practices in their career.

DEPARTMENT OF COMPUTER SCIENCE AND ENGINEERING

5
CBIT–B.Tech(R22)–CSE

ADVANCED WEB APPLICATION DEVELOPMENT


(20A05506)
III B. Tech. I Semester CSE (R20) PROGRAM OUTCOMES

POs PO STATEMENT

Engineering knowledge: Apply the knowledge of mathematics, science,


engineeringfundamentals and an engineering specialization for the solution
PO1 of complex engineering problems.

Problem analysis: Identify, formulate, research literature, and analyses complex


engineering problems reaching substantiated conclusions using first principles
PO2 of mathematics, natural sciences and engineering sciences.

Design/development of solutions: Design solutions for complex engineering


problems and design system components or processes that meet the specified
needs with appropriate consideration for public health and safety, and cultural,
PO3 societal, and environmental considerations.

Conduct investigations of complex problems: Use research-based knowledge


andresearch methods including design of experiments, analysis and
PO4 interpretation of data and synthesis of the information to provide valid
conclusions.

Modern tool usage: Create, select, and apply appropriate techniques, resources
andmodern engineering and IT tools, including prediction and modeling to
PO5 complex engineering activities, with an understanding of the limitations.

The engineer and society: Apply reasoning informed by the contextual


knowledge toassess societal, health, safety, legal and cultural issues and the
PO6 consequent responsibilities relevant to the professional engineering
practice.

6
CBIT–B.Tech(R22)–CSE
Environment and sustainability: Understand the impact of the professional
engineering solutions in societal and environmental contexts, and demonstrate
PO7 the knowledge of, and need for sustainable development.

Ethics: Apply ethical principles and commit to professional ethics and


PO8 responsibilities and norms of the engineering practice.

Individual and team work: Function effectively as an individual, and as


PO9 amember or leader in diverse teams, and in multidisciplinary settings.

Communication: Communicate effectively on complex engineering activities


with the engineering community and with t h e society at large, such as, being
able to comprehend and write effective reports and design documentation, make
PO10 effective presentations, give and receive clear instructions.

Project management and finance: Demonstrate knowledge and understanding of


the engineering and management principles and apply these to one‟s own work,
as a member and leader in a team, to manage projects and in multidisciplinary
PO11 environments.

Life-long learning: Recognize the need for, and have the preparation and
PO12 ability to engage in independent and life-long learning in the broadest context
of technological change.

Program Specific Outcomes –(PSO)


Computer Science & Engineering program students will be able to

Apply Engineering Practices and Principles to provide Software &Hardware


PSO1 solutions.
Conduct investigation, address real time engineering problems, analyze, design
solutions in real time domains of computer science.
PSO2
Adaptability to changing work environment, good interpersonal skills in
PSO3 appreciation of professional ethics and societal responsibilities.

7
ADVANCED WEB APPLICATION DEVELOPMENT MANUAL R20III-I SEM

CBIT–B.Tech(R22)–CSE

DEPARTMENT OF COMPUTER SCIENCE AND ENGINEERING

GENERAL INSTRUCTIONS:
1. The experiments have been designed to be performed within the laboratory time.
2. To successfully complete the experiment in one lab turn, come prepared to the
laboratory.
3. Read the experiment in advance.
4. To Install python lab software.
5. Open the Idle shell and go to file menu to open new script.
6. In the new script to write python programs. And save it go run.
7. Record stepwise observe the outputs for each program.
8. Get the observation signed by the instructor.
9. Always take safety precautions with using computers.

Page 8
Chaitanya Bharathi Institute of Technology ,Proddatur
ADVANCED WEB APPLICATION DEVELOPMENT MANUAL R20 III-I SEM

1.Design a Student Profile Data Management System for a college. Create a Database and its
associated tables.

Web Server:

1. A server commonly refers to a computer program that receives and responds to requests
made over a network.

2.A web server is used for storing and transferring a website's content. A web server sends
all the text, video, application data, graphics, and other content that users may require. The
web server requests the website's data each time a user clicks a link or begins a download.

Database Server:
Database servers are used to store and manage databases that are stored on
the server and to provide data access for authorized users.
Private IP Address:
1.An IP address is the identifier that enables your device to send or receive data packets
across the internet.
2.It holds information related to your location and therefore making devices available for
two-way communication.
3.Private IP address of a system is the IP address that is used to communicate within the
same network. Using private IP data or information can be sent or received within the
same network.

Port Address:

1.A port number is a way to identify a specific process to which an internet or other network
message is to be forwarded when it arrives at a server.
2.Port is an address of a 16-bit unsigned integer number which ranges from 0 to 65535

Server-side Programming:

1.Server-side programming refers to the process of writing and executing code on the server
side of a client-server architecture.
2. Users don't see this development because it happens on servers.

3. Server side uses coding languages like: Python, PHP, Java, C#

Page 9
Chaitanya Bharathi Institute of Technology ,Proddatur
ADVANCED WEB APPLICATION DEVELOPMENT MANUAL R20 III-I SEM

Common server-side tasks include:


 Coding dynamic websites
 Developing web applications
 Connecting websites to databases
 Implementing content management systems
 Making sure programs retrieve information properly
 Ensuring systems are safe from hackers
 Restoring and backing up files

Web Server solution stack:


1. A web stack is the collection of software used for web development that
incorporates, at a minimum, an operating system (OS), a programming language,
database software and a web server.
2. A web stack, also known as a web application stack, is a type of solution stack.

Task:

How to install XAMPP server on windows

We will learn how to install the XAMPP server on windows platform step by step. Follow
the below steps and install the XAMPP server on your system.

Step 1: Click on the above link provided to download the XAMPP server according to
your window requirement.

Page 10
Chaitanya Bharathi Institute of Technology ,Proddatur
ADVANCED WEB APPLICATION DEVELOPMENT MANUAL R20 III-I SEM

Step 2: After downloading XAMPP, double click on the downloaded file and allow XAMPP
to make changes in your system. A window will pop-up, where you have to click on
the Next button.

Step 3: Here, select the components, which you want to install and click Next.

Step 4: Choose a folder where you want to install the XAMPP in your system and
click Next.

Page 11
Chaitanya Bharathi Institute of Technology ,Proddatur
ADVANCED WEB APPLICATION DEVELOPMENT MANUAL R20 III-I SEM

Step 5: Click Next and move ahead.

Step 6: XAMPP is ready to install, so click on the Next button and install the XAMPP.

Page 12
Chaitanya Bharathi Institute of Technology ,Proddatur
ADVANCED WEB APPLICATION DEVELOPMENT MANUAL R20 III-I SEM

Step 7: A finish window will display after successful installation. Click on


the Finish button.

Step 8: Choose your preferred language.

Page 13
Chaitanya Bharathi Institute of Technology ,Proddatur
ADVANCED WEB APPLICATION DEVELOPMENT MANUAL R20 III-I SEM

Step 9: XAMPP is ready to use. Start the Apache server and MySQL and run the php
program on the localhost.

Step 10: If no error is shown, then XAMPP is running successfully.

How to run PHP programs in XAMPP

How to run PHP programs in XAMPP PHP is a popular backend programming language.
PHP programs can be written on any editor, such as - Notepad, Notepad++,

Page 14
Chaitanya Bharathi Institute of Technology ,Proddatur
ADVANCED WEB APPLICATION DEVELOPMENT MANUAL R20 III-I SEM

Dreamweaver, etc. These programs save with .php extension, i.e., filename.php inside the
htdocs folder.

For example - p1.php.

As I'm using window, and my XAMPP server is installed in C drive. So, the path for the
htdocs directory will be "C:\xampp\htdocs".

PHP program runs on a web browser such as - Chrome, Internet Explorer, Firefox, etc.
Below some steps are given to run the PHP programs.

Step 1: Create a simple PHP program like hello world.

1. <?php
2. echo "Hello World!";
3. ?>

Step 2: Save the file with hello.php name in the htdocs folder, which resides inside the
xampp folder.

Step 3: Run the XAMPP server and start the Apache and MySQL.

Step 4: Now, open the web browser and type localhost http://localhost/hello.php on your
browser window.

Step 5: The output for the above hello.php program will be shown as the screenshot
below:

2.Design a Student Profile Data Management System for a college. Create a Database and its
associated tables.
Step-1:
Page 15
Chaitanya Bharathi Institute of Technology ,Proddatur
ADVANCED WEB APPLICATION DEVELOPMENT MANUAL R20 III-I SEM

Open phpMyAdmin in localhost  Window opened

Step-2:
In that select databases Create Database and give the name.

CREATE DATABSE:

Page 16
Chaitanya Bharathi Institute of Technology ,Proddatur
ADVANCED WEB APPLICATION DEVELOPMENT MANUAL R20 III-I SEM

Step-3:
Observe the remaining databases Student Database found.

Step-4:
Open the Database and Create the table name Student-info.
Page 17
Chaitanya Bharathi Institute of Technology ,Proddatur
ADVANCED WEB APPLICATION DEVELOPMENT MANUAL R20 III-I SEM

Step-5:

Mention the column name values in it.


Step-6:
If we want to see the structure.Go to structure column in php myadmin page.

Step-7:
By using Insert command insert the table values by using insert tab you may passible to insert
the values.
Page 18
Chaitanya Bharathi Institute of Technology ,Proddatur
ADVANCED WEB APPLICATION DEVELOPMENT MANUAL R20 III-I SEM

INSERT VALUES INTO THE DATABASE:

Step-8:
In this use Insert command you may also enter.
The values like this I st row inserted.
II nd row inserted.

Page 19
Chaitanya Bharathi Institute of Technology ,Proddatur
ADVANCED WEB APPLICATION DEVELOPMENT MANUAL R20 III-I SEM

Page 20
Chaitanya Bharathi Institute of Technology ,Proddatur
ADVANCED WEB APPLICATION DEVELOPMENT MANUAL R20 III-I SEM

Page 21
Chaitanya Bharathi Institute of Technology ,Proddatur
ADVANCED WEB APPLICATION DEVELOPMENT MANUAL R20 III-I SEM

Step-9:
And again create the table name student marks.

Step-10:
Insert the value using Insert tab.

Page 22
Chaitanya Bharathi Institute of Technology ,Proddatur
ADVANCED WEB APPLICATION DEVELOPMENT MANUAL R20 III-I SEM

Step-11:
Insert the values using Insert command.

Page 23
Chaitanya Bharathi Institute of Technology ,Proddatur
ADVANCED WEB APPLICATION DEVELOPMENT MANUAL R20 III-I SEM

Step-12:
If we want to see the result  Print option in the phpMyAdmin Home Screen you will see the
result page as follows.

Page 24
Chaitanya Bharathi Institute of Technology ,Proddatur
ADVANCED WEB APPLICATION DEVELOPMENT MANUAL R20 III-I SEM

Step-13:
If you want to Move, Copy, Alter, Delete, Drop a database from phpMyAdmin the Go to 
operations we may see the operations like as below.
OPERATIONS:
HOW TO ALTER, MOVE, COPY

3.Develop a PHP application and run it with a command-line interpreter

Step:1 Path Setting:


open Computer-> Properties-> Advanced System Settings-> Environment Veriables->System
variables -> New-> variable name:path , variable value: C:\xampp\php\php
-

Page 25
Chaitanya Bharathi Institute of Technology ,Proddatur
ADVANCED WEB APPLICATION DEVELOPMENT MANUAL R20 III-I SEM

Page 26
Chaitanya Bharathi Institute of Technology ,Proddatur
ADVANCED WEB APPLICATION DEVELOPMENT MANUAL R20 III-I SEM

Step:2 Program:
open Notepad-> save the program with .php extinction.
Ex: fact.php
<?php
$count = 0;

$num = 2;
while ($count <30 )
{
$div_count=0;
for ( $i=1; $i<=$num; $i++)

{
if (($num%$i)==0)
{
$div_count++;
}

}
if ($div_count<3)
{
echo $num." , ";
$count=$count+1;

}
$num=$num+1;
}
?>
Step:3 Run Program:

open CMD and complete the path settings

Page 27
Chaitanya Bharathi Institute of Technology ,Proddatur
ADVANCED WEB APPLICATION DEVELOPMENT MANUAL R20 III-I SEM

Step:4

Compile/Run for output

Page 28
Chaitanya Bharathi Institute of Technology ,Proddatur
ADVANCED WEB APPLICATION DEVELOPMENT MANUAL R20 III-I SEM

4. Develop an Add Student Profile Page which accepts all student details including
photo and display them in order.

PROGRAMS:
Addstudent.php
<?php include('../header.php') ?>

<div class="header-section jumbotron">


<div class="container">
<div class="row">
<div class="col-md-12">
<h2 class="text-center">
WELCOME TO ADMIN DASHBOARD
<span><a href="logout.php" class="btnbtn-
success" style="float: right;">LOGOUT</a><span>
</h2>
</div>
</div>
</div>
</div>

<div class="admin-dashboard text-center">


<div class="container">

<div>
<div class="row">

Page 29
Chaitanya Bharathi Institute of Technology ,Proddatur
ADVANCED WEB APPLICATION DEVELOPMENT MANUAL R20 III-I SEM

<div class="col-md-6 col-md-offset-3 jumbotron" >


<a href="addstudent.php" class="btnbtn-info btn-lg">INSERT STUDENT
DETAIL</a><br><br>
<a href="updatestudent.php" class="btnbtn-info btn-lg">UPDATE STUDENT
DETAIL</a><br><br>
<a href="deletestudent.php" class="btnbtn-info btn-lg">DELETE STUDENT
DETAIL</a>
</div>
</div>
</div>
</div>
</div>

<?php include('../footer.php') ?>

Deleterecord.php
<?php
include('../dbcon.php');
$delete_id = $_GET['Delete'];
$profile_pic = $_GET['Picture'];

$sql = "delete from `student` where id = $delete_id";

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

Page 30
Chaitanya Bharathi Institute of Technology ,Proddatur
ADVANCED WEB APPLICATION DEVELOPMENT MANUAL R20 III-I SEM

if ($result) {
unlink("../databaseimg/".$profile_pic);
echo '<script>window.open("deletestudent.php?deleted=Record deleted
successfully","_self")</script>';
}

?>

Deletestudent.php
<?phprequire_once('../include/Session.php');?>
<?phprequire_once('../include/Functions.php');?>
<?php echo AdminAreaAccess(); ?>

<?php include('../header.php') ?>


<?php include('admin.header.php') ?>

<div class="container">
<div class="row">
<div class="col-md-6 col-md-offset-3 jumbotron ">
<div style="text-align: center;">
<form action="<?php echo
htmlspecialchars($_SERVER["PHP_SELF"]);?>" method="post"
enctype="multipart/form-data" >

Page 31
Chaitanya Bharathi Institute of Technology ,Proddatur
ADVANCED WEB APPLICATION DEVELOPMENT MANUAL R20 III-I SEM

Choose Standard: <select name="standard"


class="btnbtn-info" style="margin-right: 30px;">
<option>Select</option>
<option>1st</option>
<option>2nd</option>
<option>3rd</option>
<option>4th</option>
<option>5th</option>
</select>
<input type="submit" name="search" value="SEARCH"
class="btnbtn-success">
</form>
</div>
</div>
</div>

<table class="table table-striped table-bordered table-responsive text-center">


<h2 class="text-center">Student's Information</h2>
<tr>

<th class="text-center">Roll No.</th>


<th class="text-center">Full Name</th>
<th class="text-center">City</th>
<th class="text-center">Parent Phone No.</th>

Page 32
Chaitanya Bharathi Institute of Technology ,Proddatur
ADVANCED WEB APPLICATION DEVELOPMENT MANUAL R20 III-I SEM

<th class="text-center">Profile Pic</th>


<th class="text-center">Delete</th>

</tr>
<?php
include('../dbcon.php');
if (isset($_POST['search'])) {

$standard = $_POST['standard'];

$sql = "SELECT * FROM `student` WHERE `standard` = '$standard'";

$result = mysqli_query($conn,$sql);
if (mysqli_num_rows($result)>0) {
while ($DataRows = mysqli_fetch_assoc($result)) {
$Id = $DataRows['id'];
$RollNo = $DataRows['rollno'];
$Name = $DataRows['name'];
$City = $DataRows['city'];
$Pcontact = $DataRows['pcontact'];
$ProfilePic = $DataRows['image'];
?>
<tr>
<td><?php echo $RollNo;?></td>
<td><?php echo $Name; ?></td>
Page 33
Chaitanya Bharathi Institute of Technology ,Proddatur
ADVANCED WEB APPLICATION DEVELOPMENT MANUAL R20 III-I SEM

<td><?php echo $City; ?></td>


<td><?php echo $Pcontact; ?></td>
<td><imgsrc="../databaseimg/<?php echo
$ProfilePic;?>" alt="img"></td>
<td><a href="deleterecord.php?Delete=<?php
echo $Id; ?>&Picture=<?php echo $ProfilePic;?>" class="btnbtn-
danger">Delete</a></td>
</tr>
<?php

} else {
echo "<tr><td colspan ='6' class='text-center'>No Record
Found</td></tr>";
}
}

?>

</table>
</div>

<div class="container">
<div class="row">
Page 34
Chaitanya Bharathi Institute of Technology ,Proddatur
ADVANCED WEB APPLICATION DEVELOPMENT MANUAL R20 III-I SEM

<div class="col-md-6 col-md-offset-3">


<h2><?php echo @$_GET['deleted']; ?></h2>
</div>
</div>
</div>

<?php include('../footer.php') ?>

Admin.header.php
<div class="header-section jumbotron">
<div class="container">
<div class="row">
<div class="col-md-12">
<h2 class="text-center">
<span><a href="admindash.php" class="btnbtn-
success" style="float: left;">BACK TO DASHBOARD</a><span>
WELCOME TO ADMIN DASHBOARD
<span><a href="logout.php" class="btnbtn-
success" style="float: right;">LOGOUT</a><span>
</h2>
</div>
</div>
</div>
Page 35
Chaitanya Bharathi Institute of Technology ,Proddatur
ADVANCED WEB APPLICATION DEVELOPMENT MANUAL R20 III-I SEM

</div>

Imageupload.php
<?php

$imgName = $_FILES['simg']['name'];
$imgTmpName =$_FILES['simg']['tmp_name'];
$imgSize = $_FILES['simg']['size'];
$imgError = $_FILES['simg']['error'];
$imgExt = explode('.', $imgName);

$actualFileExt = strtolower(end($imgExt));
$allowed = array('jpg','jpeg','png','pdf');

if (in_array($actualFileExt, $allowed)) {
if ($imgError === 0) {
if ($imgSize< 50000) {
$fileDestination = '../databaseimg/'.$imgName;
move_uploaded_file($imgTmpName, $fileDestination);
} else {
echo "file size is too big";
}
}else{

Page 36
Chaitanya Bharathi Institute of Technology ,Proddatur
ADVANCED WEB APPLICATION DEVELOPMENT MANUAL R20 III-I SEM

echo "error while uploading your file";


}
}else {
echo "you cannot upload files of this type";
}

Updaterecord.php
<?phprequire_once('../include/Session.php');?>
<?phprequire_once('../include/Functions.php');?>
<?php echo AdminAreaAccess(); ?>

<?php

include('../dbcon.php');
$update_record= $_GET['Update'];
$sql = "select * from student where id = '$update_record'";
$result = mysqli_query($conn,$sql);

while ($data_row = mysqli_fetch_assoc($result)) {


$update_id = $data_row['id'];
$Roll = $data_row['rollno'];
$Name = $data_row['name'];
$City = $data_row['city'];
$Pcontact = $data_row['pcontact'];

Page 37
Chaitanya Bharathi Institute of Technology ,Proddatur
ADVANCED WEB APPLICATION DEVELOPMENT MANUAL R20 III-I SEM

$Standard = $data_row['standard'];

?>

<?php include('../header.php') ?>

<?php include('admin.header.php') ?>

<div class="container jumbotron">


<div class="row">
<div class="col-md-6 col-md-offset-3">
<h2 class="text-center">UPDATE STUDENT DETAIL</h2>
<form action="UpdateRecord.php?update_id=<?php echo
$update_id;?>" method="post" enctype="multipart/form-data">
<div class="form-group">
Roll No.:<input type="text" class="form-control"
name="roll" value="<?php echo
$Roll;?>" >
</div>
<div class="form-group">

Full Name:<input type="text" class="form-control"


name="fullname" value="<?php echo

Page 38
Chaitanya Bharathi Institute of Technology ,Proddatur
ADVANCED WEB APPLICATION DEVELOPMENT MANUAL R20 III-I SEM

$Name;?>" placeholder="full name" required>


</div>
<div class="form-group">
City: <input type="text" class="form-control"
name="city" value="<?php echo $City;?>" required>
</div>
<div class="form-group">

Parent Phone No.:<input type="text" class="form-


control" name="pphone" value="<?php echo $Pcontact;?>" required>
</div>
<div class="form-group">

Standard:<input type="number" class="form-control"


name="standard" value="<?php echo $Standard;?>" required>
</div>

<button type="submit" name="submit" class="btnbtn-


success btn-lg">UPDATE</button>
</form>
</div>
</div>
</div>

<?php include('../footer.php') ?>

Page 39
Chaitanya Bharathi Institute of Technology ,Proddatur
ADVANCED WEB APPLICATION DEVELOPMENT MANUAL R20 III-I SEM

<?php
//This php code block is for editing the data that we got after clicking on update
button
if (isset($_POST['submit'])) {
if (!empty($_POST['roll']) && !empty($_POST['fullname'])) {

include ('../dbcon.php');
$id = $_GET['update_id'];
$roll=$_POST['roll'];
$name=$_POST['fullname'];
$city=$_POST['city'];
$pphone=$_POST['pphone'];
$standard=$_POST['standard'];

$sql = "UPDATE student SET rollno = '$roll', name = '$name',


city='$city', pcontact = '$pphone', standard = '$standard' WHERE id = '$id'";

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

if ($Execute) {
$_SESSION['SuccessMessage'] = " Data Updated
Successfully";
Redirect_to("updatestudent.php");

Page 40
Chaitanya Bharathi Institute of Technology ,Proddatur
ADVANCED WEB APPLICATION DEVELOPMENT MANUAL R20 III-I SEM

?>

Logout.php
<?php
session_start();
session_destroy();
header('location:../login.php');

?>
OUTPUT:

Page 41
Chaitanya Bharathi Institute of Technology ,Proddatur
ADVANCED WEB APPLICATION DEVELOPMENT MANUAL R20 III-I SEM

Page 42
Chaitanya Bharathi Institute of Technology ,Proddatur
ADVANCED WEB APPLICATION DEVELOPMENT MANUAL R20 III-I SEM

Page 43
Chaitanya Bharathi Institute of Technology ,Proddatur
ADVANCED WEB APPLICATION DEVELOPMENT MANUAL R20 III-I SEM

Page 44
Chaitanya Bharathi Institute of Technology ,Proddatur
ADVANCED WEB APPLICATION DEVELOPMENT MANUAL R20 III-I SEM

5.Implement an effective Logging System using file in PHP.

The most important thing is when and how to log errors. You can log PHP errors at your
will when working in the dev mode. Either create a PHP error log file or save them as
notifications on different channels, as you get the convenience of logging errors per your
requirements.

Different Types of PHP Errors

PHP errors occur when something is off-base within the code. They can be as complex
as calling an incorrect variable or as simple as missing a semicolon. You must
understand the kind of errors you face to solve them effectively.

Warning Error

PHP warning errors alert about a problem that may cause a more critical error in the long
run. Warning errors do not break down the code execution and commonly occur when
using a file path that doesn’t exist.

1. <?php
2. echo "Warning error"';
3. include("external_file.php");
4. ?
5. >

There is no file named “external_file,” so the output will display an error message box,
and the execution will not break down.

Notice Error

Notice errors are minor; like warning errors, they don’t halt code execution. These errors
can confuse the system in analyzing if there’s an actual mistake or if it’s just the standard
code. Notice errors usually occur when the script needs access to an undefined variable.

Page 45
Chaitanya Bharathi Institute of Technology ,Proddatur
ADVANCED WEB APPLICATION DEVELOPMENT MANUAL R20 III-I SEM

Syntax Error

A syntax error is often caused by parsed, misused, or missing symbols. When the
compiler catches the error, it terminates the script.

Parse/syntax errors are caused by:

 Unclosed brackets or quotes

 Missing or extra semicolons or parentheses

 Misspellings

Here’s an example of a parse error message:

PHP Parse error: syntax error, unexpected ‘5’ (L_NAME), expecting ‘)’ i
n /home/u802426761/domains/username/public_html/wp-config.php on line 3
2

Fatal Error

A fatal error happens when the code calls the function, but the function itself isn’t
characterized. Unlike other PHP errors, a fatal error breaks down the execution and
sometimes crashes the application as well. There are three types of fatal errors:

 A startup fatal error happens when the framework can’t run the code due to a
mistake during installation.

 A compile-time fatal error occurs when the developer uses an undefined function,
class, or non-existent variable or data.

 Runtime fatal error is similar to a compile-time fatal error, but happens during the
program execution.

Here’s an example of a PHP fatal error:

Page 46
Chaitanya Bharathi Institute of Technology ,Proddatur
ADVANCED WEB APPLICATION DEVELOPMENT MANUAL R20 III-I SEM

PHP Fatal error: Call to undefined function get_header() in /var/www/us


ername/public/blog/wp-content/themes/theme/index.php on line 37

Another reason for a fatal error is exceeding the execution time:

Fatal error: Maximum execution time of 30 seconds exceeded in /home/use


rname/domains/domain.com/public_html/wp-includes/class-phpmailer.php on
line 737

Enable Error Logging in php.ini

To log errors in PHP, open the php.ini file and uncomment/add the following lines of
code.

1. error_reporting = E_ALL & ~E_NOTICE


2.
3. error_reporting = E_ALL & ~E_NOTICE | E_STRICT
4.
5. error_reporting = E_COMPILE_ERROR|E_RECOVERABLE_ERROR|E_ER…
_ERROR
6.
7. error_reporting = E_ALL & ~E_NOTICE

If you want to enable PHP error logging in individual files, add this code at the top of the
PHP file.

1. ini_set('display_errors', 1);
2.
3. ini_set('display_startup_errors', 1);
4.
5. error_reporting(E_ALL);

Now, you must enable only one statement to parse the log errors in the php.ini file:

display_errors = on.

Now, you can easily see logged errors in your browser.

Page 47
Chaitanya Bharathi Institute of Technology ,Proddatur
ADVANCED WEB APPLICATION DEVELOPMENT MANUAL R20 III-I SEM

How to log effectively (PHP)

<?php

ini_set("display_errors",1);

ini_set("log_errors",1);

ini_set("error_log","temp/error_log.php");

$x=5;

$y=0;

if($y==0)

trigger_error("Cannot divide by zero",E_USER_ERROR);

try

$value=$x%$y;

catch(Exception $e)

Page 48
Chaitanya Bharathi Institute of Technology ,Proddatur
ADVANCED WEB APPLICATION DEVELOPMENT MANUAL R20 III-I SEM

throw new Exception("Divide error..");

$message="Exception:".$e->getMessage();

?>

OUTPUT:

Page 49
Chaitanya Bharathi Institute of Technology ,Proddatur
ADVANCED WEB APPLICATION DEVELOPMENT MANUAL R20 III-I SEM

6. Design and Implement Class diagram representation of Student Management


system for a college using PHP.
Class Diagram for Student Management System:

Step 1: Familiari ze Class Diagram Components


Class Diagram Co mponent s – are used to creat e Class Diagram which were
present ed here. t hey should be familiar ized before you build t he Class Diagram.

Class Name: The name of t he class appear s in t he upper port ion. Whet her you’re
t alking about t he classifier or an object .

Class Attributes: The class’s att ribut es are found in t he middle port ion. Use t his
sect ion t o describe t he class’s charact erist ics. When specifying a specific inst ance
of a class, t his is only required.
Class operations: are included in t he bottom part (met hods). Each act ion has it s
own line when displayed in a list format . The operat ions are t he met hods by
which a class int eract s wit h dat a.
Class Connections: Depending on t he access modifier, each class has a different
level o f access (visibilit y). The following are t he access levels and t he symbo ls
Page 50
Chaitanya Bharathi Institute of Technology ,Proddatur
ADVANCED WEB APPLICATION DEVELOPMENT MANUAL R20 III-I SEM

t hat correlat e to t hem:


• Public (+)
• Privat e (-)
• Prot ect ed (#)
• Package (~)
• Der ived (/)
• St at ic (under lined)

Each of t hese class diagram component s shows t he overall Class st ruct ure.
Emphasizing t he Syst em’s st ruct ure would be much easier by using t hese Class
Diagram symbo ls.

Step 2: Determine the targeted users


Aft er t he symbo l familiar izat ion, you’ll need to det ermine your t arget ed users.
Your t arget ed users will be t he ones to use your project .
Your project is St udent Management Syst em for school, t hen your users would be
t he St aff, Admin and t he st udent s. You may ask t hem of t he commo n act ivit ies
t hat t hey do when doing t ask in st udent management . These infor mat ion of t he
diagram wit h t he next st ep.

Step 3: Analyse the activities included


Analyzat ion is ver y import ant in cr eat ing a class diagram. It will help you
underst and t he work of t he diagram and avoid t he unwant ed errors.

Step 4: Plot the Class Diagram


To plot t he class diagram you will need t he class name, it s attribut es, met hods,
and t heir access (visibilit y). You wi ll base t he diagram fro m t he evaluat ed
infor mat ion to have t he exact Class Diagram.

7. Develop Add Student Profile Page to store data into the database and develop a
webpage to retrieve the student details based on the Roll Number or any unique ID.
Admindash.php
<?phprequire_once('../include/Session.php');?>

<?phprequire_once('../include/Functions.php');?>
<?php echo AdminAreaAccess(); ?>

Page 51
Chaitanya Bharathi Institute of Technology ,Proddatur
ADVANCED WEB APPLICATION DEVELOPMENT MANUAL R20 III-I SEM

<?php include('../header.php') ?>

<div class="header-section jumbotron">


<div class="container">
<div class="row">

<div class="col-md-12">
<h2 class="text-center">
WELCOME TO ADMIN DASHBOARD
<span><a href="logout.php" class="btnbtn-success"
style="float: right;">LOGOUT</a><span>
</h2>
</div>

</div>
</div>
</div>

<div class="admin-dashboard text-center">

<div class="container">

<div>
<div class="row">
<div class="col-md-6 col-md-offset-3 jumbotron" >

<a href="addstudent.php" class="btnbtn-info btn-lg">INSERT STUDENT DETAIL</a><br><br>


<a href="updatestudent.php" class="btnbtn-info btn-lg">UPDATE STUDENT DETAIL</a><br><br>
<a href="deletestudent.php" class="btnbtn-info btn-lg">DELETE STUDENT DETAIL</a>
</div>
</div>

</div>
Page 52
Chaitanya Bharathi Institute of Technology ,Proddatur
ADVANCED WEB APPLICATION DEVELOPMENT MANUAL R20 III-I SEM

</div>
</div>

<?php include('../footer.php') ?>

header.phpAdmin.php
<div class="header-section jumbotron">

Page 53
Chaitanya Bharathi Institute of Technology ,Proddatur
ADVANCED WEB APPLICATION DEVELOPMENT MANUAL R20 III-I SEM

<div class="container">
<div class="row">
<div class="col-md-12">
<h2 class="text-center">
<span><a href="admindash.php" class="btnbtn-success"
style="float: left;">BACK TO DASHBOARD</a><span>
WELCOME TO ADMIN DASHBOARD

<span><a href="logout.php" class="btnbtn-success"


style="float: right;">LOGOUT</a><span>

</h2>
</div>
</div>
</div>
</div>

Updatestudent.php
<?phprequire_once('../include/Session.php');?>
<?phprequire_once('../include/Functions.php');?>
<?php echo AdminAreaAccess(); ?>

<?php include('../header.php') ?>


<?php include('admin.header.php') ?>
<div class="container">
<div class="row">

<div class="col-md-6 col-md-offset-3 jumbotron ">


<div style="text-align: center;">
<form action="<?php echo
htmlspecialchars($_SERVER["PHP_SELF"]);?>" method="post" enctype="multipart/form-data" >

Page 54
Chaitanya Bharathi Institute of Technology ,Proddatur
ADVANCED WEB APPLICATION DEVELOPMENT MANUAL R20 III-I SEM

Choose Standard: <select name="standard" class="btnbtn-info"


style="margin-right: 30px;"> <option>Select</option>

<option>1st</option>
<option>2nd</option>
<option>3rd</option>
<option>4th</option>
<option>5th</option>

</select>
<input type="submit" name="search" value="SEARCH"
class="btnbtn-success">
</form>
</div>
</div>
</div>

<?php
echo ErrorMessage();
echo SuccessMessage();
?>

<table class="table table-bordered table-striped table-responsive">


<h2 class="text-center">Update Student's Information</h2>
<tr class="text-center">
<th>Roll No.</th>
<th>Standard</th>

<th>Full Name</th>
<th>City</th>
<th>parent phone No.</th>
<th>Profile Pic</th>
Page 55
Chaitanya Bharathi Institute of Technology ,Proddatur
ADVANCED WEB APPLICATION DEVELOPMENT MANUAL R20 III-I SEM

<th>Update</th>
</tr>
<?php
include('../dbcon.php');
if (isset($_POST['search'])) {

$standard = $_POST['standard'];

$sql = "SELECT * FROM `student` WHERE `standard` = '$standard'";

$result = mysqli_query($conn,$sql);
if (mysqli_num_rows($result)>0) {
while ($DataRows = mysqli_fetch_assoc($result)) {
$Id = $DataRows['id'];
$RollNo = $DataRows['rollno'];

$Name = $DataRows['name'];
$City = $DataRows['city'];
$Pcontact = $DataRows['pcontact'];
$Standard = $DataRows['standard'];
$ProfilePic = $DataRows['image'];

?>
<tr class="text-center">
<td><?php echo $RollNo;?></td>
<td><?php echo $Standard;?></td>
<td><?php echo $Name; ?></td>

<td><?php echo $City; ?></td>


<td><?php echo $Pcontact; ?></td>

Page 56
Chaitanya Bharathi Institute of Technology ,Proddatur
ADVANCED WEB APPLICATION DEVELOPMENT MANUAL R20 III-I SEM

<td>
<imgsrc="../databaseimg/<?php echo
$ProfilePic;?>" alt="img"><br><br>
<form action="UpdateImg.php" method="post"
enctype="multipart/form-data">
<input type="file" name="updateimg"
style="float: left;" class="btnbtn-info btn-sm">
<input type="hidden" name="id"
value="<?php echo $Id; ?>">
<input type="submit" name="submitimg"
value="UPDATE" class="btnbtn-warning btn-sm" style="float: right;"><br>
</form>
</td>
<td><a href="UpdateRecord.php?Update=<?php echo $Id;
?>" class="btnbtn-warning">UPDATE</a></td>

</tr>
<?php

} else {
echo "<tr><td colspan ='7' class='text-center'>No Record
Found</td></tr>";
}
}

?>

</table>
Page 57
Chaitanya Bharathi Institute of Technology ,Proddatur
ADVANCED WEB APPLICATION DEVELOPMENT MANUAL R20 III-I SEM

</div>
<div class="container">
<div class="row">
<div class="col-md-6 col-md-offset-3">
<h2><?php echo @$_GET['updated']; ?></h2>

</div>
</div>
</div>

<?php include('../footer.php');?>

Updateimage.php
<?phprequire_once('../include/Session.php');?>
<?phprequire_once('../include/Functions.php');?>
<?php include('../dbcon.php') ?>
Page 58
Chaitanya Bharathi Institute of Technology ,Proddatur
ADVANCED WEB APPLICATION DEVELOPMENT MANUAL R20 III-I SEM

<?php
if(isset($_POST['submitimg'])) {

$ID = $_POST['id'];
$imgName = $_FILES['updateimg']['name'];

$imgTmpName =$_FILES['updateimg']['tmp_name'];
$imgSize = $_FILES['updateimg']['size'];
$imgError = $_FILES['updateimg']['error'];
$imgExt = explode('.', $imgName);
$actualFileExt = strtolower(end($imgExt));

$allowed = array('jpg','jpeg','png','pdf');

if (in_array($actualFileExt, $allowed)) {

if ($imgError === 0) {

if ($imgSize< 50000) {
$fileDestination = '../databaseimg/'.$imgName;
move_uploaded_file($imgTmpName, $fileDestination);
} else {
echo "file size is too big";

}
} else {
echo "error while uploading your file";
}

} else {
echo "you cannot upload files of this type";

Page 59
Chaitanya Bharathi Institute of Technology ,Proddatur
ADVANCED WEB APPLICATION DEVELOPMENT MANUAL R20 III-I SEM

if(empty($imgName)) {
$_SESSION['ErrorMessage'] = "Please Select
an Image First";
Redirect_to("updatestudent.php");
} else {

$sql = "update student set image ='$imgName'


where id = '$ID' ";
$result = mysqli_query($conn,$sql);

if ($result) {

$_SESSION['SuccessMessage']
= "Image Updated Successfully";
Redirect_to("updatestudent.php");
}
}
}

?>

8.Design and develop a User Authentication System using cookies, sessions, JWT, and
SMS API. Also, identify which is suitable for your application.

Connection.php
<?php
$servername="localhost";

Page 60
Chaitanya Bharathi Institute of Technology ,Proddatur
ADVANCED WEB APPLICATION DEVELOPMENT MANUAL R20 III-I SEM

$username="root";
$password="";
$dbname="college";
$conn=mysqli_connect($servername,$username,$password,$dbname);
if($conn)

{
echo"";
}
else
{

echo"connection failed! phir se check karo bhai";


}
?>
login.php
<?php

session_start();
include('connection.php');
?>
<form action=" " method="POST">
Username<input type="text" name="username"><br><br>

Password<input type="text" name="password"><br><br>


<input type="submit" name="submit" value="LOGIN">
</form>
<?php
if (isset($_POST["submit"]))

{
$user=$_POST["username"];

Page 61
Chaitanya Bharathi Institute of Technology ,Proddatur
ADVANCED WEB APPLICATION DEVELOPMENT MANUAL R20 III-I SEM

$psd=$_POST["password"];
$query="SELECT*FROM STUDENT WHERE USERNAME='$user' ";
$data=mysqli_query($conn,$query);
$total=mysqli_num_rows($data);
if($total==1)

{
$_SESSION['user_name']=$user;
echo("login successful");
header('location:welcome.php');
}

else
{
echo("login failed!");
}
}

?>

Welcome.php
<?php
session_start();

echo"welcome".$_SESSION['user_name'];
?>

OUTPUT:

Page 62
Chaitanya Bharathi Institute of Technology ,Proddatur
ADVANCED WEB APPLICATION DEVELOPMENT MANUAL R20 III-I SEM

Page 63
Chaitanya Bharathi Institute of Technology ,Proddatur
ADVANCED WEB APPLICATION DEVELOPMENT MANUAL R20 III-I SEM

9. Secure your PHP applications from common vulnerabilities like Injection, XSS,
Session hijacking and fixation, and other exceptions.
admin.php
<?php
session_start();

echo "Session ID: " .session_id() . "<hr/>";

if(!isset($_SESSION["admin"]))

{
Page 64
Chaitanya Bharathi Institute of Technology ,Proddatur
ADVANCED WEB APPLICATION DEVELOPMENT MANUAL R20 III-I SEM

echo "<h1 style='color: red;'>You are not authorized to view this page.</h1>
<a href='index.php'>Back to login</a>";

else

echo "<h2>You are logged in as " . $_SESSION["admin"]["user"] . " and you have been

granted access.</h2>";

echo "<a href='logout.php'>Logout</a>";

……………………………………………………………………………………..
Index.php
<?phpsession_start(); ?>

<?php
if(isset($_SESSION["admin"]))
{
header("Location: admin.php");

exit();
Page 65
Chaitanya Bharathi Institute of Technology ,Proddatur
ADVANCED WEB APPLICATION DEVELOPMENT MANUAL R20 III-I SEM

if(isset($_POST["username"], $_POST["password"]))

$username = htmlentities($_POST["username"]);
$password = htmlentities($_POST

["password"]);

if($username == "Muneera" && $password == "Muneera")

{
//session_regenerate_id(true); //uncomment this line for improved session security

$_SESSION["admin"] = array(
"user" => $username,
);

header("Location: admin.php");

exit();

else
Page 66
Chaitanya Bharathi Institute of Technology ,Proddatur
ADVANCED WEB APPLICATION DEVELOPMENT MANUAL R20 III-I SEM

{
echo "<div style='color: red'>Incorrect username / password.</div>"; }
}
?>
<!DOCTYPE

html>

<html>
<head>
<meta charset="utf-8">
<title>Login</title>
</head>

<body>
<?php

echo "Session ID: " .session_id(); ?><hr/>


<form method="post">
<p>Username: <input

type="text" name="username" /></p>

<p>Password: <input type="password"

name="password" /></p>
<input type="submit" value="Login" />
</form>
</body>
</html>

…………………………………………………………………………………………………….
logout.php
Page 67
Chaitanya Bharathi Institute of Technology ,Proddatur
ADVANCED WEB APPLICATION DEVELOPMENT MANUAL R20 III-I SEM

<?php
session_start();
//session_regenerate_id(true); //uncomment this line for improved session security
session_unset();
session_destroy();

header("Location: index.php");
exit();

………………………………………………
Output:

Page 68
Chaitanya Bharathi Institute of Technology ,Proddatur
ADVANCED WEB APPLICATION DEVELOPMENT MANUAL R20 III-I SEM

10.Design a Administrator Portal through which administrator can be able to upload student
data into the database, Download the student data, Generate certificates, etc.
Index.php
<?php
header('content-type:image/jpeg');

$font=realpath('arial.ttf');
$image=imagecreatefromjpeg("format.jpg");
$color=imagecolorallocate($image, 51, 51, 102);
$date=date('d f, y');
imagettftext($image, 18, 0, 880, 188, $color, $font, $date);

imagejpeg($image);
Page 69
Chaitanya Bharathi Institute of Technology ,Proddatur
ADVANCED WEB APPLICATION DEVELOPMENT MANUAL R20 III-I SEM

imagedestroy($image);
?>
OUTPUT:

11. Host a PHP-MySQL based application on the internet using the Web Hosting Service
Provider of your choice (000webhost, Hostinger, Heroku, Godaddy, etc.)

Step 1: Sign up on your control panel with the login information

Page 70
Chaitanya Bharathi Institute of Technology ,Proddatur
ADVANCED WEB APPLICATION DEVELOPMENT MANUAL R20 III-I SEM

Step 2: Go to your Cpanel file manager option.

Step 3: From the file manager option go to public.html> Click public.html> here you will
find an option named upload> Click the upload option.

Page 71
Chaitanya Bharathi Institute of Technology ,Proddatur
ADVANCED WEB APPLICATION DEVELOPMENT MANUAL R20 III-I SEM

Step 4: After clicking on the upload option you will get a select file section where you can
upload your own PHP file. You must know the file size before uploading.

Page 72
Chaitanya Bharathi Institute of Technology ,Proddatur
ADVANCED WEB APPLICATION DEVELOPMENT MANUAL R20 III-I SEM

 That’s how you can upload your PHP file to the server.

Step 5: Now you need to extract the Zip PHP file

You can also edit your PHP file from index.php. You need to go index.php> click on the
right button> there you will find out the edit option.

Page 73
Chaitanya Bharathi Institute of Technology ,Proddatur
ADVANCED WEB APPLICATION DEVELOPMENT MANUAL R20 III-I SEM

After editing, you need to click on save changes. Then your editing will be saved on the
system.

Page 74
Chaitanya Bharathi Institute of Technology ,Proddatur
ADVANCED WEB APPLICATION DEVELOPMENT MANUAL R20 III-I SEM

Step6: If your website uses a database, you need to import it along with your website
files:

 Create a new MySQL database and user.

Page 75
Chaitanya Bharathi Institute of Technology ,Proddatur
ADVANCED WEB APPLICATION DEVELOPMENT MANUAL R20 III-I SEM

 Access your newly created database with PHPMYadmin.

 Use the Import section to upload backup files to your database.

 Update MySQL database connection details (hostname, database name,


username, password) in its configuration files.
Page 76
Chaitanya Bharathi Institute of Technology ,Proddatur
ADVANCED WEB APPLICATION DEVELOPMENT MANUAL R20 III-I SEM

 That’s how you can update database information.


Final step: Once the website files are uploaded and the database is created, it’s the final
time to check!!

When your domain name points to your web host, enter the domain name in your
browser and see if it points you to your website. If you follow all the instructions correctly,
your website will be displayed like this:

That’s how you can host a PHP website on your server.

12. Host a PHP-MySQL based application on the internet using the Cloud Hosting Provider of
your choice (Amazon Web Services, Google Cloud Platform, DigitalOcean, etc.)

Step 1: Register with Google Cloud Platform


At the end of this step, you will have signed up for the Google Cloud Platform free trial.

Begin by creating a Google Cloud Platform account, by browsing to https://cloud.google.com/ and


choosing the "Start your free trial" option. You will need an existing Google account to log in and
Page 77
Chaitanya Bharathi Institute of Technology ,Proddatur
ADVANCED WEB APPLICATION DEVELOPMENT MANUAL R20 III-I SEM

sign up for the free trial; if you don’t have one, you can create one here (remember to keep track of
your account username and password, because you’ll need them in the next step).

Once you’ve signed in, provide Google with some personal information and your credit card details.

Page 78
Chaitanya Bharathi Institute of Technology ,Proddatur
ADVANCED WEB APPLICATION DEVELOPMENT MANUAL R20 III-I SEM

It’s important to note that you’re signing up for a free trial and your credit card won’t be billed
unless you migrate to a paid account. The trial includes $300 of free credit, valid for 60 days. Once
the trial ends, your account will automatically be paused and you’ll only be charged if you explicitly
choose to upgrade to a paid account.

The Google elves will go away for a minute or so to verify your information and if all is well, you
will be redirected to the Google Developers Console, which allows you to manage your billing
account, create new projects and get support. You should see that your free trial is now active in the
billing credits section.

You should also receive an account confirmation email, which tells you that your account is good to
go.

Bitnami uses the Google Compute Engine API in order to manage and launch cloud servers, so this
is a good time to enable the API. Plus, new cloud servers always launch within a project, so you’ll
also need to create a project. Both these tasks are easy to do from the Google Developers Console.
Follow these steps:

 While you’re logged in to the Google Developers Console, select the "Projects" menu
item and click the "Create Project" button.
 Enter a name for the project (such as "My Bitnami Project") and make a note of the
auto-generated project ID.

Page 79
Chaitanya Bharathi Institute of Technology ,Proddatur
ADVANCED WEB APPLICATION DEVELOPMENT MANUAL R20 III-I SEM

 Click "Create" to create and activate the project. You should now see it in the project
listing.

 Select the new project name in the project listing, and you’ll be transferred to the project
information page.
 Select the "APIs" menu item in the left navigation bar.
 Look through the list of APIs, or use the API search box to search for the term "compute
engine". Find and turn on the Google Compute Engine API.

Page 80
Chaitanya Bharathi Institute of Technology ,Proddatur
ADVANCED WEB APPLICATION DEVELOPMENT MANUAL R20 III-I SEM

 Verify that the Google Compute Engine API now appears in the list of enabled APIs.

Step 2: Register with Bitnami


At the end of this step, you will have created a Bitnami account.

The next step is to create a Bitnami account, so that you can launch a cloud server with LAMP
packaged by Bitnami image. If you have a Google, Microsoft or Github account, you can use your
credentials from those services with Oauth to create your Bitnami account.

If you don’t have accounts with those services (or you don’t want to use them), you can use your
email address and password to create a Bitnami account, as described below:

 Head to the Bitnami sign-up page.


 Enter your name and email address.
 Choose a password.
 Review and agree to the Bitnami terms of service.

Page 81
Chaitanya Bharathi Institute of Technology ,Proddatur
ADVANCED WEB APPLICATION DEVELOPMENT MANUAL R20 III-I SEM

Then, use the "Sign up" button to create your account.

Bitnami will send you an email with a verification link which you’ll need to click or browse to, to
activate your account. This will also sign you in to your Bitnami account.

Page 82
Chaitanya Bharathi Institute of Technology ,Proddatur
ADVANCED WEB APPLICATION DEVELOPMENT MANUAL R20 III-I SEM

Step 3: Connect your Google Cloud Platform and Bitnami Accounts


At the end of this step, your Bitnami Launchpad for Google Cloud Platform will be configured and
you will be ready to provision a cloud server.

The easiest way to set up your Google cloud server with LAMP packaged by Bitnami is via
the Bitnami Launchpad for Google Cloud Platform, which gives you a simple control panel to
provision, start, stop, connect to and check status of your cloud servers. However, to use it, you
must first connect your Google Cloud Platform and Bitnami accounts.

To do this:

 Log in to your Bitnami account if you’re not already logged in.


 Browse to https://google.bitnami.com/.
 Select the "Sign in with Bitnami" link in the top right corner.

The Launchpad will recognize your Bitnami credentials and automatically sign you in.

The next step is to set up an administrative password and connect your Google Cloud Platform
account with your Bitnami account. To do this:

 Select "Virtual Machines" in the Launchpad menu.


 Since this is your first time, you’ll be prompted to set up your Bitnami password vault
by entering an administrative password. Enter a hard-to-guess password.

Page 83
Chaitanya Bharathi Institute of Technology ,Proddatur
ADVANCED WEB APPLICATION DEVELOPMENT MANUAL R20 III-I SEM

The Bitnami Vault password offers an additional level of protection against misuse:
you’ll need to enter it when performing certain operations, such as creating new cloud
servers. Again, make sure you note it down for future reference.

Your Bitnami Vault password is different from your Google Account password.

 Once your password has been accepted, you’ll be redirected back to the Launchpad
page. Select "Virtual Machines" again in the Launchpad menu.
 You’ll be transferred to an authorization page, where you can confirm that the Bitnami
Launchpad is authorized to connect to your Google Cloud Platform account. Click the
"Accept" button on the page to proceed.

Page 84
Chaitanya Bharathi Institute of Technology ,Proddatur
ADVANCED WEB APPLICATION DEVELOPMENT MANUAL R20 III-I SEM

 You’ll now be redirected back to the Bitnami Launchpad, and asked to select a project
within which to launch new cloud servers. Enter the project ID you noted in Step 1.

Your Google Cloud Platform and Bitnami accounts are now connected, and you can launch new
cloud servers with Bitnami application stacks.

Page 85
Chaitanya Bharathi Institute of Technology ,Proddatur
ADVANCED WEB APPLICATION DEVELOPMENT MANUAL R20 III-I SEM

Step 4: Provision a Google Cloud Platform Server


At the end of this step, your Google Cloud Platform server will be running and you will be able to
access it through your Web browser.

To provision your Google Cloud Platform server:

 Select "Library" in the Launchpad menu.


 Look through the list of applications available in Bitnami until you find LAMP Stack.
Select it and click "Launch". If required, enter your administrative password.

 Define a name, size and region for your cloud server. You can choose from a "micro"
server, which uses a shared CPU to a "high CPU" server, which has 16 dedicated virtual
cores. For more information, refer to the Google Compute Engine pricing sheet.

A "micro" server will work just fine for most PHP application development tasks.

Page 86
Chaitanya Bharathi Institute of Technology ,Proddatur
ADVANCED WEB APPLICATION DEVELOPMENT MANUAL R20 III-I SEM


 Confirm your selection by hitting the "Create Virtual Machine" button at the end of the
page.

The Bitnami Launchpad will now begin spinning up the new server. The process usually takes a few
minutes: a status indicator on the page provides a progress update.

Page 87
Chaitanya Bharathi Institute of Technology ,Proddatur
ADVANCED WEB APPLICATION DEVELOPMENT MANUAL R20 III-I SEM

Once the cloud server has been provisioned, the status indicator will show that it’s "running", and
the Bitnami Launchpad page will display the server details, including its IP address.

At this point, you should be able to browse to the cloud server, either by clicking the link in the
Bitnami Launchpad (a new browser tab will open) or entering the cloud server IP address directly
into your browser’s address bar. You should see a welcome page like the one below (just so you
know, it’s served up by Apache, which is part of LAMP packaged by Bitnami).

Page 88
Chaitanya Bharathi Institute of Technology ,Proddatur
ADVANCED WEB APPLICATION DEVELOPMENT MANUAL R20 III-I SEM

Once the server is provisioned, you need to gather the security credentials you will need to begin
using it. To do this:

 Go back to the Bitnami Launchpad for Google Cloud Platform page and in the "Virtual
Machines" section, select the running server. This will launch the server information
page.
 From the server information page, download the .ppk file which contains the SSH access
credentials you will need to connect to the server. Typically, this file is named using the
format bitnami-[google-project]-[nn].ppk. If you’re using Mac OS X or Linux, you
should instead download the corresponding .pem file.

Page 89
Chaitanya Bharathi Institute of Technology ,Proddatur
ADVANCED WEB APPLICATION DEVELOPMENT MANUAL R20 III-I SEM

 By default, Bitnami Launchpad creates a user account named 'user' and an auto-
generated password when a new server is provisioned. You will need this password
when accessing Bitnami-supplied applications (including MySQL). Go back to the
server information screen, look in the "Credentials" section of the "Application Info"
panel, and display and make a note of the application password.

The Launchpad page also includes controls to reboot, shut down or delete the server.
Page 90
Chaitanya Bharathi Institute of Technology ,Proddatur
ADVANCED WEB APPLICATION DEVELOPMENT MANUAL R20 III-I SEM

Step 5: Test PHP and MariaDB


At the end of this step, you will have logged in to your cloud server and verified that PHP, MariaDB
and phpMyAdmin are working correctly.

You can now connect to the cloud server and test PHP to make sure it’s working correctly and has
all the extensions you need. The easiest way to do this is with PuTTY, a free SSH client for
Windows and UNIX platforms.

 Download the PuTTY ZIP archive from its website.


 Extract the contents to a folder on your desktop.
 Double-click the putty.exe file to bring up the PuTTY configuration window.
 Enter the host name of your cloud server into the "Host Name (or IP address)" field, as
well as into the "Saved Sessions" field.
 Click "Save" to save the new session so you can reuse it later.

Page 91
Chaitanya Bharathi Institute of Technology ,Proddatur
ADVANCED WEB APPLICATION DEVELOPMENT MANUAL R20 III-I SEM

 In the "Connection → SSH → Tunnels" section, create a secure tunnel for the
phpMyAdmin application by forwarding source port "8888" to destination port
"localhost:80".
 Click the "Add" button to add the secure tunnel configuration to the session.

 In the "Connection → SSH → Auth" section, select the private key file (*.ppk) you
saved in the previous step.

Page 92
Chaitanya Bharathi Institute of Technology ,Proddatur
ADVANCED WEB APPLICATION DEVELOPMENT MANUAL R20 III-I SEM

 In the "Connection → Data" section, enter the username 'bitnami' into the "Auto-login
username" field.

 Go back to the "Session" section and save your changes by clicking the "Save" button.
 Click the "Open" button to open an SSH session to the server.
 PuTTY will first ask you to confirm the server’s host key and add it to the cache. Go
ahead and click "Yes" to this request.

Page 93
Chaitanya Bharathi Institute of Technology ,Proddatur
ADVANCED WEB APPLICATION DEVELOPMENT MANUAL R20 III-I SEM

You should now be logged in to your cloud server.

By default, LAMP packaged by Bitnami includes running Apache and MariaDB servers, and all the
packages that come with the stack are located in the /opt/bitnami directory. Your first step should be
to create a phpinfo.php file in the Apache web server root at /opt/bitnami/apache2/htdocs directory
to verify PHP’s capabilities.

shell> cd /opt/bitnami/apache2/htdocs
shell> echo "<?phpphpinfo(); ?>" >phpinfo.php

Page 94
Chaitanya Bharathi Institute of Technology ,Proddatur
ADVANCED WEB APPLICATION DEVELOPMENT MANUAL R20 III-I SEM

Once the file has been copied, browse to http://[your-cloud-server-hostname]/phpinfo.php and you
should see the output of the phpinfo() command.

With this, you know that your PHP installation is configured and working correctly.

You can also check that MariaDB is working by launching the MariaDB command-line client at the
shell prompt.

shell>mysql -u root -p

When prompted, enter the application password retrieved in the previous step. The client should
start up and connect to the local MariaDB server, displaying a welcome message as shown below.

Page 95
Chaitanya Bharathi Institute of Technology ,Proddatur
ADVANCED WEB APPLICATION DEVELOPMENT MANUAL R20 III-I SEM

You should also be able to access phpMyAdmin through the secure SSH tunnel you created, by
browsing to http://127.0.0.1:8888/phpmyadmin.

To log in, use username 'root' with the application password from the previous step.

In case you’d like to troubleshoot errors or modify the configuration for Apache, PHP or MariaDB -
for example, adjusting the maximum upload file size in PHP or changing the path to the MariaDB
data directory - here are the locations for key configuration and log files in LAMP packaged by
Bitnami:

Configuration file(s) Log file(s)

Page 96
Chaitanya Bharathi Institute of Technology ,Proddatur
ADVANCED WEB APPLICATION DEVELOPMENT MANUAL R20 III-I SEM

Apache /opt/bitnami/apache2/conf/httpd.conf /opt/bitnami/apache2/logs/erro

PHP /opt/bitnami/php/etc/php.ini -

MariaDB /opt/bitnami/mariadb/conf/my.cnf _/opt/bitnami/mariadb/logs/my

Usually, you’ll need to restart your server(s) for your changes to take effect. LAMP packaged by
Bitnami includes a control script that lets you easily stop, start and restart Apache, MariaDB and
PHP. The script is located at /opt/bitnami/ctlscript.sh. Call it without any arguments to restart all
services:

shell>sudo /opt/bitnami/ctlscript.sh restart

Or use it to restart a specific service only by passing the service name as argument - for example
'mariadb':

shell>sudo /opt/bitnami/ctlscript.sh restart mariadb

image::common/mariadb-restart.jpg

Step 6: Deploy the XAMPP Application to the Cloud Server


At the end of this step, your PHP/MariaDB application will be running in the cloud.

Your cloud server is now provisioned, secured and has a functional PHP/MariaDB environment. All
that’s left is for you to transfer your application code from your local XAMPP environment to your
cloud server and set up the database.

The easiest way to transfer files to the server is with FTP or SFTP. Although you can use any
FTP/SFTP client, I like FileZilla, a cross-platform, open source and feature-rich client. Download it
from the FileZilla website and install it using the automated installer - it’s a quick process, only
requiring you to agree to the license, choose the components (the default selection is usually fine)
and specify the installation directory.

Page 97
Chaitanya Bharathi Institute of Technology ,Proddatur
ADVANCED WEB APPLICATION DEVELOPMENT MANUAL R20 III-I SEM

Once FileZilla is installed, launch it and you’ll arrive at the main split-screen interface, one side for
your local directories and the other for remote directories.

To connect to the cloud server and deploy your application, follow these steps:

Page 98
Chaitanya Bharathi Institute of Technology ,Proddatur
ADVANCED WEB APPLICATION DEVELOPMENT MANUAL R20 III-I SEM

 Use the "Edit → Settings" command to bring up FileZilla’s configuration settings.


 Within the "Connection → SFTP" section, use the "Add keyfile" command to select the
private key file for your server. FileZilla will use this private key to log in to the cloud
server.

 Use the "File → Site Manager → New Site" command to bring up the FileZilla Site
Manager, where you can set up a connection to your cloud server.
 Enter your server host name or IP address and user name.
 Select "SFTP" as the protocol and "Normal" as the logon type.

Page 99
Chaitanya Bharathi Institute of Technology ,Proddatur
ADVANCED WEB APPLICATION DEVELOPMENT MANUAL R20 III-I SEM

 Use the "Connect" button to connect to the cloud server and begin an SFTP session.
 On the remote server side of the window, change to
the /opt/bitnami/apache2/htdocs directory
 On the local server side of the window, change to the directory containing your
application code.
 Upload your XAMPP application code to the remote directory by dragging and dropping
the files from the local server to the cloud server (you can back up the original contents
of the directory if you wish, by downloading them first).

 Once the files are transferred, log in to the server console using PuTTY.
 Create a database for the application using the MariaDB command-line client (you can
use phpMyAdmin if you prefer a graphical interface). For example, since the application
is a to-do list, let’s call the database 'tasks'.
mysql> CREATE DATABASE tasks;
 Follow best practices and create a separate MariaDB user with privileges to access only
this database.
mysql> GRANT ALL ON tasks.* TO 'tasks'@'localhost' IDENTIFIED BY
'klio89';

Page 100
Chaitanya Bharathi Institute of Technology ,Proddatur
ADVANCED WEB APPLICATION DEVELOPMENT MANUAL R20 III-I SEM

 If required, update database credentials in your application. Then, install the application
schema in the new database (assuming you already uploaded it with the application
code). For example, you can use the following command with the MariaDB command-
line client:
shell>mysql -u tasks -D tasks -p < schema/tasks.sql

If you’re logged in to phpMyAdmin, you can also import the database schema from your local
XAMPP system. To do this, select the "Import" tab of the phpMyAdmin dashboard, select the file
containing the schema, and click "Go" to have the tables created in your selected database.
Page 101
Chaitanya Bharathi Institute of Technology ,Proddatur
ADVANCED WEB APPLICATION DEVELOPMENT MANUAL R20 III-I SEM

You can also learn more about using phpMyAdmin to back up and restore databases.

Browse to your cloud server’s host name and your application should be active. Here are a few
screenshots of the example to-do list application running on the cloud server.

Congratulations! You’ve successfully deployed your XAMPP application in the cloud

Page 102
Chaitanya Bharathi Institute of Technology ,Proddatur
ADVANCED WEB APPLICATION DEVELOPMENT MANUAL R20 III-I SEM

VIVA QUESTIONS
1. What is PHP?
2. How to create database connection and query in PHP?
3. Explain the difference b/w static and dynamic websites?
4. What is "echo" in PHP?
5. What is "print" in PHP?
6. What is the difference between "echo" and "print" in PHP?
7. How a variable is declared in PHP?
8. What are the ways to define a constant in PHP?
9. What are the ways to define a constant in PHP?
10. What is the array in PHP?
11. What is the array in PHP?
12. Explain some of the PHP string functions?
13. What are the methods to submit form in PHP?
14. What is a session?
15. What is $_SESSION in PHP?
16. What is the difference between session and cookie?
17. Write syntax to open a file in PHP?
18. How to delete file in PHP?
19. What are the different types of errors in PHP?
20. How to stop the execution of PHP script?

Page 103
Chaitanya Bharathi Institute of Technology ,Proddatur

You might also like