Sie sind auf Seite 1von 49

.

LIST OF CONTENTS
1. INTRODUCTION
1.1

Purpose.......................................................................................12

1.2

Scope & Objectives....................................................................12

1.3

Definitions, Acronyms and Abbreviations.................................13

1.4

Overview....................................................................................14

2. METHODOLOGY
2.1

Project Perspective....................................................................15
2.1.1

System Interfaces..........................................................15

2.1.2

User Interfaces..............................................................15

2.1.3

Hardware Interfaces......................................................16

2.1.4

Software Interfaces........................................................17

2.1.5

Communication Interfaces.............................................17

2.1.6

Memory Constraints.......................................................17

2.2

User Characteristics....................................................................17

2.4

Constraints.................................................................................20

2.5

Assumptions and Dependencies..............................................20

2.6

Apportioning of Requirements..................................................20

3. SPECIFIC REQUIREMENTS
3.1

External Interfaces......................................................................21

3.2

Functions....................................................................................21

3.3

Performance Requirements.......................................................21

3.4

Logical Database Requirements................................................21

3.5

Design Constraints......................................................................22

3.6

Software System Attributes........................................................25

3.7

3.6.1

Maintainability.................................................................26

3.6.2

Portability........................................................................26

3.6.3

Availability.......................................................................26

3.6.4

Reliability.........................................................................27

3.6.5

Security...........................................................................27

Organizing the Specific Requirements.............................,,,,,,...26


3.7.1

System Mode.................................................................26

3.7.2

User Class......................................................................26

3.7.3

Objects............................................................................26

3.7.4

Use Cases......................................................................27

3.7.5

Features..........................................................................27

4. INTRODUCTION OF PHP
4.1

Introduction to PHP for web development...................................29

4.2

Benefits and importance of PHP.................................................29

4.3

Basic requirements of PHP.........................................................30

4.4

Types of PHP..............................................................................30

4.5

Installation of tools.......................................................................31

4.6

How to access the PHP files.......................................................35

4.7

Comments in PHP.......................................................................36

4.8

Data types...................................................................................36

4.9

PHP Variables.............................................................................37

5. PHP WITH FUNCTIONS


5.1

User defined functions.................................................................38

5.2

PHP Strings.................................................................................38

5.3

Concatenate Operator.................................................................39

5.4

Some built-in functions................................................................39

5.5

PHP Include and Require Functions............................................39

6. PHP WITH WEB DESIGN


6.1

HTML Forms................................................................................41

6.2

Database Connectivity.................................................................43

6.3

Closing Connection......................................................................43

6.4

Creating HTML form using MySQL..............................................44

7. OOPS CONCEPT IN PHP


7.1

Type Hinting.................................................................................47

7.2

Object Cloning.............................................................................47

8. WORKING WITH FILES


8.1

Uploading a file............................................................................49

8.2

Providing restrictions on Upload..................................................50

8.3

Downloading a file........................................................................50

9. SATAE MANAGEMENT
9.1

Cookies........................................................................................52

9.2

Session........................................................................................53

10. MYSQL DATABASE AND SQL


10.1

Creating Database Tables.........................................................56

10.2

What is SQL...............................................................................58

11. PROJECT PROFILE


11.1

Tools used for working in PHP..................................................60

11.2

My Project.................................................................................62

12. CONCLUSION
13. REFERANCES

LIST OF FIGURES
1.

INTRODUCTION

1.4

Overview...............................................................................................14

2.

METHODOLOGY

2.1

Project Perspective...............................................................................15
2.1.2 User Interfaces...........................................................................16

2.2

User Characteristics..............................................................................18

3.

SPECIFIC REQUIREMENTS

3.4

Logical Database Requirements..........................................................21


3.4 (a) Login.......................................................................................22
3.4 (b) Sign Up...................................................................................22

3.5

Design Constraints................................................................................22
3.5 (a) DFD 0 Level............................................................................23
3.5 (b) DFD 1 Level............................................................................24
3.5 (c)

3.7

ER Diagram.............................................................................26

Organizing the Specific Requirements..................................................26


3.7.4 Use cases..................................................................................27

4.

INTRODUCTION TO PHP

4.3

Basic requirements of PHP...................................................................30

4.5

Installation of tools................................................................................31

4.9

PHP Variables.......................................................................................37

5.

PHP WITH FUNCTIONS

5.3

Concatenate Operator............................................................................38

5.5

PHP Include and Require Functions......................................................40

6.

PHP WITH WEB DESIGN

6.1

HTML Forms..........................................................................................42

6.4

Creating HTML form using MySQL........................................................45

7.

OOPS CONCEPT IN PHP

7.2

Object Cloning........................................................................................48

8.

WORKING WITH FILES

8.1

Uploading a file......................................................................................49

8.3

Downloading a file..................................................................................51

11.

PROJECT PROFILE

11.1

Tools used for working in PHP


11.1 (a) Wamp Server..........................................................................61
11.1 (b) PHP MyAdmin.........................................................................61
11.1 (c) PHP Designer.........................................................................62

ABSTRACT
The main objective of this project College Management System is to provide an
easy way to circulate all the functionalities of a college, and manipulate data and
information about administration, students and staff easily and also to manage
the task related to the college students/ employees/ administration and to reduce
time to searching of appropriate candidates in college view. College Management
System synchronizes the working of all the departments. It looks on all aspects of
a college, its students, faculties, Departments, marks and other co curricular
activities.

The College Management System is basically build to provide a system to


manage a college. Without automation the management of the college has
become an unwieldy task. The end users day-to-day jobs of managing a college
will be simplified by a considerable amount through the automated system. The
system will be able to handle many services to take care of all the students as
well as staff in a quick manner. The system should be user appropriate, easy to
use, provide easy recovery of errors and have an overall end user high
subjective satisfaction.

There are two end users for the CMS. The end users are the staff and the
students and other one is the administrator. Both user types can access the

website through Login ID. The general Management System will be restricted to
management users. This system provides the detail structure of the college
campus and its departments.

CHAPTER 1
INTRODUCTION

This system provides the detail structure of the college campus and its
departments. College Management System synchronizes the working of all the
departments. It looks on all aspects of a college, its students, faculties,
Departments, marks and other co curricular activities.
The following subsections of the report provide an overview of the entire project.

Purpose
The report will provide a detailed description of the requirements for the
College Management System (CMS). This SRS will allow for a complete
understanding of what is to be expected of the CMS to be constructed.
The clear understanding of the CMS and its functionality will allow for the
correct software to be developed for the end user and will be used for the
development of the future stages of the project. This report will provide the
foundation for the project. From this report, the CMS can be designed,
constructed, and finally tested.
This report will be used by the software engineers constructing the CMS and the
system end users.The software engineers will use the SRS to fully understand
the expectations of this CMS to construct the appropriate software. The college
end users will be able to use this report as a test to see if the software
engineers will be constructing the system to their expectations. If it is not to their
expectations the end users can specify how it is not to their liking and the
software engineers will change the SRS to fit the end users needs.

Scope

The main scope of this project College Management System is to provide an


easy way to circulate all the functionalities of a college, and manipulate data and
information about administration, students and staff easily and also to manage
the task related to the college students/employees/administration and to reduce
time to searching of appropriate candidates in college view.

The software product to be produced is a College Management System which


will
automate the major college operations. These three subsystems functionality will
be described in detail in section 2-Overall Description.
There are two end users for the CMS. The end users are the staff and the
students and other one is the administrator. Both user types can access the
website through Login ID. The General Management System will be restricted
to management users. This system provides the detail structure of the college
campus and its departments.
College Management System synchronizes the working of all the departments.
It looks on all aspects of a college, its students, faculties, Departments, marks
and other co curricular activities. The College Management Systems objectives
is to provide a system to manage a college.
Without automation the
management of the college has become an unwieldy task. The end users dayto-day jobs of managing a college will be simplified by a considerable amount
through the automated system. The system will be able to handle many services
to take care of all the students as well as staff in a quick manner. The system
should be user appropriate, easy to use, provide easy recovery of errors and
have an overall end user high subjective satisfaction.

Definitions, Acronyms, and Abbreviations


PHP PHP: Hypertext Preprocessor
WAMP Windows Apache MySQL PHP
CMS College Management System
DFD Data Flow Diagram
CFD Context Flow Diagram
SQL Structured Query Language
ER Entity Relationship
Subjective satisfaction The overall satisfaction of the system
End users The people who will be actually using the system

1.4 Overview
The report is organized into two main sections. The first is The Overall
Description and the second is the Specific Requirements. The Overall
Description will describe the requirements of the CMS from a general high
level perspective.
The Specific Requirements section will describe in detail the requirements
of the system.
The implementation of College Management starts with entering and updating
master records like students, employee details, e-library, college information.

Fig 1.4

CHAPTER 2
METHODOLOGY
2.1

Project Perspective

The CMS is an independent standalone system. It is totally self contained.

2.1.1 System Interfaces


Students can connect both systems to retrieve information on their
academic progress.
System interface are the interfaces between the system and external
environment. In any software product, almost half of the interface with humancomputer interaction, which provide the best way for user to interact with
computer. Describe the system capacity hard disk-256 MB , RAM-1 GB. This
makes it possible to the application on different environments without any
modification to the code. The software requires a mouse or keyboard, a graphical
user environment .processor required (windows7, window 8) dual core and quad
core.
Students can connect both systems to retrieve information on their
academic progress.

2.1.2 User Interfaces


The software provides good graphical interface for the user any administrator can
operate on the system, performing the required task such as create, update,
viewing the details of the student and staff.
Allows user to view quick reports of the student like attendance and internal
marks etc in between particular time. Stock verification and search facility based
on different criteria.
The User Interface Screens are described in the table.

Table : College Management User Interface Screens


Screen Name

Description

Login

Log into the system

Sign-up

For the new users to get registered

Form

To provide the users to get registered for the college


regarding admissions and other activities

Fig 2.1.2(a)

Fig 2.1.2(b)

2.1.3 Hardware Interfaces


Server Side
The web application will be hosted on one of the departments WAMP
servers and connecting to one of the school MySQL server. The web
server is listening on the web standard port, port 80.

Client Side
The system is a web based application; clients are requiring using a
modern web browser such as Mozilla Firebox 1.5, Internet Explorer 6 and
Enable Cookies. The computer must have an Internet connection in order
to be able to access the system.
Operating System : Windows

Hard disk : 40 GB

RAM : 256 MB

Processor : Pentium(R)Dual-core CPU

2.1.4 Software Interfaces


Server Side
The UOP already has the required software to host a Java web

application. An Apache Web server will accept all requests from the client
and forward SUMS specific requests to Tomcat 5.5 Servlet
Container with J2EE 5.0 and Strut 1.2.8 hosting SUMS. A development
database will be hosted
locally (using MySQL); the production database is hosted centrally (using
Oracle).

Client Side
An OS is capable of running a modern web browser which supports HTML
version 3.2 or higher.
WAMP server

Adobe Dreamweaver

PHP Designer

WOW Slider

CSS3 Menu

2.1.5 Communication Interfaces


The system shall be a standalone product that does not require any
communication interfaces.The HTTP protocol will be used to facilitate
communications between the client and server.

2.1.6

Memory Constraints

The memory constraints include RAM of 256 MB.

2.2

User Characteristics

We have 2 levels of users.


User module : In the user module, user will check their attendance and internal
marks and college events.
Login
Forms
Reports
Window
Module wise description :
Login :
Login module is used to check whether the user is an authorized person to use
the system or not. For this the user should give the correct user name and

password.
The different types of users are -

Admin
Student
Employee
Fig 2.2

Forms :
This module consists of the following sub modules

Student Registration Form - The Student Registration Form is designed


for registering the new students details and course details.

Student Fee Form - The Student Fee Form is used to enter the students
fee details.

Student Marks Form - The Student Marks Form is designed for


submitting the semester or exam marks of the students for a particular
course or an individual student.

Student ID Form - The Student Id Form is used to create the identity


number for each student for different courses.

Employee Detail Form - The Employee details form is designed for


entering the staff details and other relevant details.

Employee ID Form - The Employee Id used to create the identity number


for each student for different course.

Reports
All the above mentioned data are stored in the back end and can be retrieved as
reports with filtering options. The Following are the reports that can be taken from

this system

Student Report
Employee Report
Course Detail Report
Fee Detail Report
Marks Detail Report

Administration module : The following are the sub modules in the


administration module.

Register user

Enter student details

Enter staff details

Student attendance update

2.3

Constraints

Any update regarding the student from their branch is to be recorded to have
update & correct values.

2.4

Assumptions and Dependencies

All the data entered will be correct and up to date. This software package is
developed using PHP as the front end which is platform independent. Its code
can be run on Linux, Unix, Windows etc. Microsoft SQL server can be used as
the back end which is supported by Windows Operating System.

2.5

Apportioning of Requirements

The audio and visual alerts will be deferred because of low importance at this
time.

CHAPTER 3
SPECIFIC REQUIREMENTS
3.1

External Interfaces

The user should be simple and easy to understand and use. Also be an
interactive interface.
The system should prompt for the user and administrator to login to the
application and for proper input criteria.

3.2

Functions

Functional requirements define the fundamental actions that system must


perform.
Students and Employee entry : In this module we can store the details of the
students and staff.
Register student and employee : In this module we can get admission and
other details of the student.

3.3

Performance Requirements

The capability of the computer depends on the performance of the software. The
software can take any number of inputs provided the database size is larger

enough. This would depend on the available memory space.


Performance requirements define acceptable response times for system
functionality.

The load time for user interface screens shall take no longer than two
seconds.

The log in information shall be verified within five seconds.

Queries shall return results within five seconds.

3.4

Logical Database Requirements

The logical database requirements include the retention of the following data
elements. This list is not a complete list and is designed as a starting point for
development.
Login
Field

Type

Null

Default

Student_Id

Varchar (20)

Yes

Null

Name

Varchar (20)

Yes

Null

Password

Varchar (20)

Yes

Null

Fig 3.4 (a)

Sign_up
Field

Type

Null

Name

Varchar (20)

Yes

Gender

Varchar (20)

Yes

Date_of_Birth

Varchar (20)

Yes

Faculty

Varchar (20)

Yes

Course

Varchar (20)

Yes

Student_Id

Varchar (20)

Yes

Email_Id

Varchar (20)

Yes

Password

Varchar (20)

Yes

NULL

Contact

Varchar (20)

Yes

NULL

Nationality

Varchar (20)

Yes

Fig 3.4(b)

3.5

Design Constraints

Each Student and Staff will be having a identity card which can be used to
identify the branch and year of the student. Depends on the status of the student
they can go to their respective class room and they can attend the classes and
for the staff , they will have a different identity card to identify them.

DFD - DATA FLOW DIAGRAM

0level DFD

1level DFD

2level DFD

A data flow diagram (DFD) is a graphical representation of the "flow" of data


through information system modelling its process aspects. A DFD shows what
kinds of information will be input to and output from the system, where the data
will come from and go to, and where the data will be stored.

Representation of Components :
Process
Transform of incoming data flow to outgoing flow.
Data Flow
Movement of data in the system.
Data Store
Data repositories for data that are not moving. It may be as

NULL

simple as a buffer or a queue or as sophisticated as a


relational database.
External Entity
Sources of destinations outside the specified system
boundary.

Fig : Data Flow Diagram

CFD - CONTROL FLOW DIAGRAM

A control flow diagram (CFD) is a diagram to describe the control flow of a


process or program.

ER-DIAGRAM - ENTITY RELATIONSHIP DIAGRAM

Entity Relationship model is an abstract way to describe a database. It usually


starts with a relational database, which stores data in tables. It is a graphical tool
to represent an algorithm. It makes different symbols representing different
instructors of algorithm.

Ellipse:

This represents the START or STOP.

Square:

This represents input or output.

3. Rectangle:
This represents process.

4. Diamond:
This represents a condition.

Fig : ER Diagram

3.6 Software System Attributes


3.6.1 Maintainability :
There will be no maintained requirement for the software. The database is
provided by the end user and therefore is maintained by this user. The College
Management System shall run in any Microsoft Windows environment.

3.6.2 Portability :
The system is developed for secured purpose, so it is cant be portable.

3.6.3 Availability :
This system will available only until the system on which it is install, and is
running. The College Management System is being developed in PHP. PHP is a
platform independent and user friendly language. Its database may be MySQL.

3.6.4 Reliability :
It specifies the factors required to establish the required reliability of the software
system at time of delivery.

3.6.5 Security :
The administrator and the users which are already registered will be able to log in
to the College Management System. Only those users who are registered and
their details are present in the database controlled by the administrator can login

and visit the internal pages of the system. those who are not registered can not
enter the system.
The administrator will have access to the databases and other details of the
students and the staff.
Access to the various subsystems will be protected by a user log in screen that
requires a user name and password.

3.7 Organizing The Specific Requirements


3.7.1 System Mode
Some systems behave quite differently depending on the mode of operation.
When organizing by mode there are two possible outlines. The choice depends
on whether interfaces and performance are dependent on mode.

3.7.2

User Class

The distinct category of users is generally referred to a user class. It consists of


those users who will use the website. In College Management System, the users
may be the administrator, students, staff and faculty members.

3.7.3

Objects

Objects represent some entities, access methods from its parent class and has
attributes that distinguish them from other objects in the system. They can
represent anything with which properties and behaviour can be associated,
where properties describe the current state of the object and behaviour shows
the way an object acts and reacts thereby changing its state.

3.7.4

Use Cases

Use cases were introduced into object analysis by Jacobson as a means of


communication with users. They are scripts that describe typical ways that a
system is or well be used. A use case is general in the sense that it doesn't
describe instances of how a system is used, but generalizes a number of
instances into a general script.Use cases should achieve the following
objectives :

To define the functional and operational requirements of the system by


defining a scenario of usage that is agreed upon by the end-user and the
software engineering team.

To provide a clear and unambiguous description of how the end-user and


the system interact with one another.

To provide a basis for validation testing

Fig : Use Case Diagram

3.7.5 Features

User friendly

Browser based
Calendar of Events

Single database management system and necessary security is provided


against unauthorized access through authorized sign-in process

Multi User environment and assigning privileges to the users


It is completely user friendly College Management Software
The complex task of report generation is an extremely easy work Using
College Management Software
Graphical Representation of admissions every year
Time Table Generation
Marks and attendance information
Mailing system
Promotion of Students to higher semesters
Teaching dairy
Lecture plan
Fee management
Full fledged Library Management System
Provides complete features of Payroll Management System like
Allowances, deductions, generation of pay slip and many more for staff
Applying Leave online
Online Examination module helps you to provide training to the students
appearing for campus interviews
Transportation management
Exporting important reports to Microsoft Excel
Total hostel management process
Placements module (under development)
User manual is provided

CHAPTER 4
INTRODUCTION OF PHP
PHP is one of the popular scripting languages for web applications and has many
advantages over the traditional web applications. This chapter provides one of
the better understanding about PHP, its history and benefits. It also provides
information about how to install and configure PHP in your system. It also
provides fair information about PHP data types, variables, operators and decision
making statements.

4.1

Introduction to PHP for Web Development & Web


Applications

PHP is the short form of ' PHP : Hypertext Preprocessor '. It is widely used
open source scripting language for web applications. The first version of PHP
was released in 1994 by Rasmus Lerdorf. Latest version of PHP is PHP 5.3
launched in 2010.
PHP is considered to be a powerful tool for developing web applications. PHP is
server - side scripting language that is embedded with HTML. PHP helps the
user to handle databases, dynamic contents, session tracking etc. PHP also
helps the user to build entire e - commerce, e - learning web portals easily. It is
integrated with a number of databases such as PostgreSQL, Informix, MySQL,
Oracle, Sybase and MS SQL and also supports protocols such as LDAP, IMAP,
POP3, HTTP etc.
One can easily develop attractive websites with the combination of client - side
scripting languages ( like Java Script / JQuery ) and server - side scripting
language ( PHP ). The syntax of PHP is almost similar to most popular languages
such as C. C++, JAVA.
PHP is a free tool which can be downloaded without any license. PHP supports
different platforms such as LINUX, UNIX, WINDOWS, Mac OS etc. which makes
the developers comfortable and create user - friendly applications.

4.2

Benefits and Importance of PHP in Web Applications

PHP is web developer's popular choice in today's web design and development.
It is considered to be a general purpose web scripting language mainly used as a
server - side web development platform. Its clarity in design, well organized

modules and better upkeep of various technologies make it different from other
popular languages available. PHP's credibility and popularity can be measured
by the fact that social networking sites such as Facebook and organizations like
Harvard University, are based on PHP. This has made possible through the fact
that PHP websites can be easily maintained, and updated from time to time
without redesigning the entire programming codes.
Following are the few advantages of PHP :

(i) Open Source - It is freely available and can be customized very easily.
(ii) Platform Independent - It is platform independent. Its code can be run
on LINUX, UNIX, WINDOWS etc.

(iii) Free of cost - It is free of cost and easily available.


4.3

Basic requirements when using PHP

(i) Client - It sends requests.


eg. Internet Explorer or Browser

(ii) Server - It provides responses.


eg. IIS, Apache, Glassfish, Tomcat

(iii) Programming Environment - It is the language in which code is


written i.e. PHP.

WEB SERVER
Web page request

Load PHP file

U
HTML response

PHP results
Fig. 4.3

4.4

Types of PHP

(i) WAMP - Windows Apache MySQL PHP


(ii) XAMP - Extension Apache MySQL PHP
(iii) LAMP - LINUX Apache MySQL PHP
(iv) MAMP - Machintosh Apache MySQL PHP

4.5

Installation of tools for working in PHP

XAMP Installation :
For installing XAMP on your windows machine follow these steps :

1.

Download XAMP from internet.

2.
Double click on XAMP installer to open the Installer Language, is shown in
figure below :

Fig. 4.5(a)
3.

Select English language from Please select a language check list.

4.
Click on OK button to open the XAMP 1.7.4 win32 setup dialog box, is
shown in the following figure :

Fig. 4.5(b)

5.
Click on OK button to go to the Welcome to the XAMP 1.7.4 Setup
Wizard window, is shown in the figure below :

Fig. 4.5(c)
6.
Click on NEXT button to open the Choose Install Location window, is
shown in the figure below :

Fig. 4.5(d)

7.
Select the Destination Folder and click NEXT button to open the XAMP
Options window, is shown in the figure below :

Fig. 4.5(e)
8.
Select the Install Apache as service and Install MySQL as service
option check box on SERVICE SECTION.
9.

Click Install button to install the XAMP 1.7.4, is shown in the figure below :

Fig. 4.5(f)

10.
After installing the XAMP 1.7.4, a Copyright section will appear, is shown
in the figure below :

Fig. 4.5(g)
11.
After Copyright screen display Completing the XAMP 1.7.4 Setup
Wizard message window will appear, is shown in the figure below :

Fig. 4.5(h)
12.

Click FINISH button to close this wizard.

13.
After Click Finish button of XAMP 1.7.4 Setup Wizard
Installation Finished ! hint message box will display on your screen :

Service

Fig. 4.5(i)
14.
Click OK button to successful install, confirmation message will appear on
your screen.
15.
Click YES to installed the XAMP 1.7.4 win32 and run the Apache and
MySQL service, is shown in the figure below :

Fig. 4.5(j)

4.6

How to access the PHP files

You can use the browser to access the file you saved in the PHP folder. You can
access the PHP files using the files from http : // localhost / test.php or http : //
127.0.0.1 / filename.php. The Web Server will be parsed by PHP and the output
will be sent to your browser.

4.7

Comments in PHP

Example :
<html>

<body>
<?php

// This is a PHP comment line ( for single line comment )


This is a PHP comment block ( for multiple line comments ) */
?>
</body>

/*

</html>

4.8

Data Types

Data types are types of data and the operations that can perform on those data.
PHP supports 8 different data types as follows :

Integers

Floats

Strings

Booleans

Arrays

Objects

Resources

Null

PHP supports two special kinds of data types Null and Resources. Resources
are not an actual data type, but storing of reference to function and resources
external to PHP.
The very common example of using the resource data type is a database call.
Null is a special kind of data type which may have only one value, which is itself
a keyword. In other words, we can say that Null is not only a data type but also a
keyword literal. A Null variable is a variable that has no value assigned to it.
Whenever we create a variable without a value, it is automatically assigned a null
value.

4.9

PHP Variables

PHP variable is used for storing a value, such as string " Hello World ! " or the
integer value 4.
Naming rules of PHP variables :

A variable starts with the $ sign and preceded by the name of the variable.

Name of variables must begin with a letter or the underscore character.

Name of variables can only contain alpha - numeric characters and


underscores ( A-z, 0 - 9 and _ ).

Name of variables should not contain spaces.

Name of variables are case - sensitive ( $y and $Y are two different


variables ).

Types of Variables :

Local

Global

Static

Output :

Parameter

Example of Local Variable :


<?php
$a = 8;

// global scope

function sample ( )
{
$ a = 5;
print $a;
// local scope
}
print $a. ' < br > ';
Fig. 4.9 sample( );
?>

CHAPTER 5
PHP WITH FUNCTIONS
5.1

User defined functions

User defined functions are created by the user for performing some specific task
in the script.
Syntax :
functionfunction_name ( )
{
// some code
}

5.2

PHP Strings

PHP supports a 256 character set of strings. A string is a series of characters,


where a character is the same as a byte.
Example :
$string_1 = " This is a string " ;
" ";

5.3

$string_2 =

// This is a string with zero character

Concatenate Operator

PHP supports only one string operator. You can join two string values together
using the concatenation operator ( . ).

Output :
My name is ABC
Example :
<?php
My name is " ;
$string2 = " ABC " ;
print $string1. " " .$string2 ;
?>

5.4

$string1 = "

Fig. 5.3

Some Built - in functions of PHP

strlen ( ) - It returns the length of a string, in characters.

strpos ( ) - It is used for finding the position of the first occurrence of a


substring in a string.

chr ( ) - It is used for returning a specific character.

echo ( ) - It is used for outputting one or more strings.

print ( ) - It is used for outputting a string.

explode ( ) - It is used for splitting a string by string.

implode ( ) - It is used for joining array elements with a string.

lcfirst ( ) - It is used for making first character of a string lowercase.

ucfirst ( ) - It is used for making first character of a string uppercase.

ucwords ( ) - It is used for making the whole string uppercase.

str_split ( ) - It is used to split all the characters of the string into


indexes.

str_shuffle ( ) - It is used to shuffle all the characters of the string.

strstr ( ) - It is used for finding the first occurrence of a string.

trim ( ) - It is used for stripping whitespace from the beginning & end of
a string.

5.5

PHP Include and Require Functions

5.5.1

include ( ) function :

include ( ) function uses all the contents of one file into another file where it
included.
Example :
Suppose you want to develop the code for a website where header and footer
will be same for all web pages then you should create a file called as "
header.php " and " footer.php " , and using include ( ) function you can use the
same header and footer in all your web pages.

header.php
<?php
print " This is my header </br> " ;
?>

Output :
This is my header
This is my home page
This is my footer

footer.php
<?php
print " This is my footer </br> " ;
?>

home.php

<?php
include ( " header.php " );
include ( " footer.php " );
print " This is my home page </br> " ;
?>

5.5.2

Fig. 5.5.1

require ( ) function :

The functionality of require function is same as that of include. The major


difference between require ( ) and include ( ) is that include does not give any
error if there is some problem in file loading, it gives only a warning. But
require ( ) gives a fatal error if file not found or something went wrong in file
loading.
Sometimes require ( ) is useful than include ( ) because we don't want to
execute our PHP script continuously after occurring some problem at run
time. Since require ( ) stops the execution of script, so it is useful in some
cases.

CHAPTER 6
PHP WITH WEB DESIGN
6.1

HTML Forms with PHP

There is a form tag < form > available in HTML for input forms.
For retrieving form's information like user inputs, PHP provides special built in
variables for handling forms - they are $_POST and $_GET variables.
$_POST : It is used for collecting values from a form with using method =
post. The information which is sent by a form using the post method is hidden
to others and has no limitation on the amount of information to send.

$_GET : It is used for collecting values from a form with using method = get.
Working of $_GET is similar to $_POST, but accessing input elements
through $_GET is something different because the user input displays at URL
area, so when sending some sensitive information like passwords we always
use $_POST.
$_REQUEST : It is also a predefined variable of PHP, which contains the
content of $_POST, $_GET and $_COOKIE. It can be used for collecting
data with both $_POST and $_GET.
Example :
< html>
< body >
< form action = " test.php " method = " post ">
Student Name : < input type = " text " name = " name " > < br >
Father's Name : < input type = " text " name = " f_name " > < br >
Email ID : < input type = " text " name = " email " > < br >
Mobile Number : < input type = " text " name = " mobile " > < br >
< button type = " submit " > Submit < / button >
< / body >
< / html >

Output :

Fig. 6.1a

When a user fills put the form above and clicks on the submit button, the
form's information is sent to a PHP file, called test.php :
< ?php
" < b> Name : < /b > " . $_POST [ ' name '] . " < br > ";
print " < b> Father's Name : < /b > " . $_POST [ ' f_name '] . " < br > ";
print " < b> Email ID : < /b > " . $_POST [ ' email '] . " < br > ";
print " < b> Mobile Number : < /b > " . $_POST [ ' mobile '] . " < br > ";
?>
Output :

Fig. 6.1b

print

6.2

Creating Connection with MySQL Database

There is a predefined mysqli_connect() function available in PHP for making


connection with MySQL database.
Syntax :
mysqli_connect ( host_name, user_name, password, database_name ) ;

HostName : Hostname or an IP address. It is an optional parameter.

UserName : Username of MySQL. It is also an optional parameter.

Password : For security purpose, use a password of database. It is

DatabaseName : Name of the database. It is also an optional

also an optional parameter.


parameter.

Example :
<?php
// create connection
$conn = mysqli_connect ( " localhost " , " user " , " 123 " , " my_database
" ); // check connection
if ( mysqli_connect_errno ( $conn ))
{
print "
Unable to connect to MySQL databse : ". mysqli_connect_error ( );
}
else
{
print "
Connection to MySQL database is done " ;
}
?>

6.3

Closing Connection

When script ends, connection will be closed automatically. For closing the
connection, there is a predefined mysqli_close ( ) function available in PHP.
Example :
<?php
// create connection
$conn = mysqli_connect ( " localhost " , " user " , " 123 " , " my_database
" ); // check connection
if ( mysqli_connect_errno ( $conn ))
{
print " Unable to connect to MySQL databse : ".mysqli_connect_error ( ) ;
}
else
{

Connection to MySQL database is done " ;


}
// close a connection
mysqli_close ( $conn ) ;
?>

6.4

print "

Creating HTML form using MySQL

You can accept values from an HTML form and store all the values in to the
database. For this we have to create a database, as we already installed
XAMP or WAMP so no need to do anything extra.
Following are the steps to create a HTML form :
Step 1 : Go to address bar and open " http : // localhost / phpmyadmin / ".
Now a webpage will open of Administrator.
Step 2 : Here we have to create a database : create a database " my_db ";
Step 3 : After creating database, create a database table namely
students. For this execute following SQL query :
CREATE TABLE students ( first_name VARCHAR (30),
last_name VARCHAR (30), city VARCHAR (30)) ;
Step 4 : Create an HTML form " test.html " ;
< html >
< body >
< form action = " test.php " method = " post " >
First Name : < input type = " text " name = " first_name " >
Last Name : < input type = " text " name = " last_name " >
City : < input type = " text " name = " city " >
< input type = " submit " >
< / form>
< / body >
< / html >

Step 5 : Create a PHP script for MySQL connectivity :


<?php
// create connection
$conn = mysqli_connect ( " localhost " , " root " , " " , " my_db " );
// check connection
if ( mysqli_connect_errno ( $conn ))
{
print " Unable
to connect to MySQL databse : ".
mysqli_connect_error ( ) ;

}
$sql = "INSERT INTO students ( first_name, last_name, city )
VALUES ( ' $_POST [first_name] ',' $_POST [last_name] ',
$_POST [city] ' )" ;
( ! mysqli_query ( $conn, $sql ))
Error :' . mysqli_error ( )) ;
record added successfully " ;
$conn ) ;

?>

'
if
{

die ( '
}
print " One
mysqli_close (

After executing " test.html " on web browser, output will be a form for
accepting values :

Fig. 6.4a

After submission of this HTML form an entry will store in our student table of
my_db database, and output will be :

Fig. 6.4b

CHAPTER 7
OOPS CONCEPTS IN PHP
7.1

Type Hinting

In PHP 5,Type Hinting is introduced. The functions are now empowered to


force parameters to be objects ( " by defining the name of a class in the
function prototype " ), interfaces and arrays. However, if the null value is used
as the default parameter value then it will entitled as an argument for any later
call. In simple words, Type Hinting allows us to restrict the type of parameters
we pass.
Example :
<?php
class Test
{
$num;
function__construct ( $a )
num=10;

}
disp (20);
$o = newTest ( );
disp ( $o );

?>

7.2

public
public

}
function disp ( Test $a )
{
echo $a -> num;

{
$this ->

Object Cloning

Object cloning creates a copy of an object with the replicated properties. If we


change the properties of one object after cloning, it should not affect the
properties of another object.
Example :
<?php
abc
{
public $num;
public function__construct ( )
{
$this -> num=20;
new abc ( );
$ob2 = clone $ob1;

class

}
$ob1 =

$ob2 -> num=30;


echo $ob1 ->num;
echo $ob2 ->num;
?>

Fig. 7.2

Output :
ob1 = 30
ob2 = 30

CHAPTER 8
WORKING WITH FILES
8.1

Uploading a File using HTML Form

For allowing users to upload files to the server, a PHP script can be used with
HTML form.
Create an Upload Form :

Following HTML codes will create a form with file upload option :
< html >
< head>
title > My Form for File Uploading < /title>
< /head >
< body >
h3 > Upload File : < /h3 >
Select a file : < /br >
< form action = " file_upload.php " method = " post "
enctype = " multipart / form-data " >
< input type = " file " name = " file " size = "50" /> < /br>
< input type = " submit " value = " Upload " />
< /form >
< /body >
< /html >

<
<

Output :

Fig. 8.1

8.2

Providing Restrictions on Upload

We can add some restrictions while uploading the file. The following code
shows that the user can upload .jpg, .gif, .jpeg and .png files and the file size
should be less than 30 KB.
<?php
$allowed = array ( "jpg", "jpeg", "gif", "png" ) ;
$exts = end ( explode (".", $_FILES ["file"] ["name"] ));
if ((( $_FILES ["file"] ["type"] == " image/gif " ) ,
$_FILES ["file"] ["type"] == " image/jpeg " ) ,
$_FILES ["file"] ["type"] == " image/png " ) ,
$_FILES["file"] ["type"] == " image/pjpeg " ) ) &&
$_FILES ["file"] ["size"] < 30000 ) && in_array ( $exts, $allowed ))
{
if ( $_FILES["file"] ["error"] > 0 )
{
print " Error :: " . $_FILES["file"] ["error"] . " < br > " ;
}
else
{
print " File Upload :
" . $_FILES["file"] ["name"] ." < br > " ;
print " File Type :
" . $_FILES["file"] ["type"] ." < br > " ;
print " File Size : " .
( $_FILES["file"] ["size"] / 1024 ) ." KB < br > " ;
print " File stored in : " .
$_FILES["file"] ["tmp_name"] ;
}
}
else
{
print " Invalid file " ;
}
?>

8.3

Downloading a file using PHP

For downloading a file, PHP provides a function readfile ( ). This function


outputs a file. It reads a file and writes it to the output buffer. It returns the
number of bytes read from the file. It returns FALSE if an error occurs, and
unless the function was called as readfile( ), an error message is printed.
Syntax :
readfile ( filename, use_include_path, context ) ;

Parameter Description :

filename : It is a required parameter, specifies the filename being

use_include_path : It is an optional parameter, set it to TRUE, if

context : It is also an optional parameter, specifies a context stream

read.

wanted to search for the file in the include_path, too.


resourve.

Example :
<?php
$myfile = ' down.gif ' ;
if ( file_exists ( $myfile ))
{
header ( ' Content-Description : File Transfer ' ) ;
header ( ' Content-Type : application/octet-stream ');
header ( ' Content-Disposition : attachment ' , filename = ' .basename
($myfile) ' );
header ( ' Content-Transfer-Encoding : binary ' );
header ( ' Expires : 0 ' );
header ( ' Cache-Control : must-revalidate ' );
header ( ' Pragma : public ' );
header ( ' Content-Length : ' .filesize ( $myfile ));
ob_clean ( );
flush ( );
readfile ($myfile);
exit;
}
?>
Output :

Fig. 8.3

CHAPTER 9

STATE MANAGEMENT
9.1

Cookies

Cookies are used for identifying users. Basically Cookie is a small file which
server embeds on the user's system (computer). Whenever the same system
requests a webpage, it sends the cookie also. Using PHP, we can set cookie
and can retrieve cookies's values.

9.1.1 Creating a cookie :


For creating a cookie, there is a built-in function setcookie ( ) available :
Syntax :
setcookie ( cookie_name, cookie_value, expire, path, domain, security );

Name : It is used to set the name of the cookie and is stored in an

Value : It is used to set the value of the named variable and is the content

Expiry : It is used to specify a future time in seconds since 00:00:00 GMT

Patch : It is used to specify the directories for which the cookie is valid. A

Domain : It can be used to specify the domain name in very large

environment variable called HTTP_COOKIE_VARS.


that you actually want to store.

on 1st Jan 1970. After this time, cookie will become inaccessible. If it is not
set then the cookie will automatically expire when the web browser will
close.
forward slash permits the cookie to be valid for all the directories.
domains and must contain at least two periods to be valid.

Note : This function should appear before the < html > tag.
Example :
<?php
$expire_time = time ( ) + 60*60*24*30 ;
setcookie ( " MyNewCookie " , "SampleCookie" , $expire_time ) ;
?>
< html >
< head >
< title > My Web Page With Cookie < /title >
< /head >
< body >
< h1> Hello < /h1>
< /body >
< /html >

9.1.2 Retrieving Cookie's Values :


For retrieving cookie's value, we have to use $_COOKIE variable.
Example :
<?php
if ( isset ( $_COOKIE [" MyNewCookie "] ))
print " Cookie value : " .$_COOKIE [" MyNewCookie "] ." < br > " ;
else
print " Cookie Not Set " ;
?>
Note : In this example, isset ( ) function is used for confirming if variable
$_COOKIE [" MyNewCookie "] is available or not.

9.1.3 Delete a Cookie :


For deleting a cookie, we have to provide expire parameter to setcookie ( )
function.
Example :
<?php
setcookie ( "User", "Ranjeet", time ( ) - 120 ) ;
setcookie ( "age", "22", time ( ) - 120 ) ;?>
< html >
< head>
< title > Deleting Cookies < /title >
< /head >
< body >
<?php
print " Delete Cookies " ;
?>
< /body >
< /html >

9.2

Session

Session is an alternative and better option of cookie. A session variable is


used to store information about a user. They are available only for a particular
application and hold information of only one single user.
When we work with an application, we have to open it, make some changes
and close the application. It is just like a session. Our system knows who we
are. It knows when we open the application and when we close it. But on the
cloud (internet) there is a problem, because our web server doesn't know who
we are and what we do since HTTP is a stateless protocol.
Session can solve this kind of problem by allowing us to store user's details

on the server for future use. Since session information is not permanent and
will be deleted after the user leaves the application (website), a unique id is
used for working with session for each visitor.

9.2.1 Start a Session :


For starting a session, there is a built-in function start_session ( ) available :
Syntax :
<?
php session_start ( ) ;
?>
Note : This function should appear before the < html > tag.

9.2.2 Create Session Variable :


When we start a session, we need to set session variables. For this we use
$_SESSION as follows :
<?php
start_session ( ) ;
$_SESSION [ 'profile_id' ] = 101 ;
$_SESSION [ 'display_name' ] = " Ranjeet " ;
?>

9.2.3 Retrieve Session Variables :


<?php
start_session ( ) ;
$_SESSION [ 'profile_id' ] = 101 ;
$_SESSION [ 'display_name' ] = " Ranjeet " ;
?>
if ( isset ( $_SESSION [ 'profile_id' ] )
{
print " Hello " . $_SESSION [ 'display_name' ] ;
}
?>

9.2.4 Destroy a Session :


For destroying a session, we have to use session_destroy ( ) or unset ( )
built-in functions of PHP. unset ( ) is used to destroy a particular session
variable as follows :
<?php
start_session ( ) ;
if ( isset ( $_SESSION [ 'profile_id' ] )
{
unset ( $_SESSION [ 'profile_id' ] ) ;
}

?>
By using session_destroy ( ) function, we can also completely destroy the
session.
Syntax :
<?php
session_destroy ( ) ;
?>

CHAPTER 10
MySQL DATABASE AND SQL
Database is a structured collection of data which can be easily accessed,
managed and updated. The concept of relational database management
helps the developers to access multiple database tables effectively for better
data management.

10.1

Creating Database Tables :

You can use ' Command line or GUI ' of Database to create database as well
as tables.

Basic structure of creating databases using Command Line :


CREATE { DATABASE / SCHEMA } [ IF NOT EXISTS ] db_name
[ create_specifications ] ...
create_specification :
[DEFAULT] CHARACTER SET = charset_name / [DEFAULT]
COLLATE [=] collation_name

Basic structure of creating database using GUI ( Graphical User


Ineterface ) as phpmyadmin. First look of phpmyadmin : To open, start
server on local then type http://localhost/phpmyadmin/

Front page with server detail and user detail which shows in right side on
below image.

Fig. 10.1a
To create a database, follow these steps :

To create database using phpmyadmin, provide database name in text box,


then click on Create button.

Fig. 10.1b
Note : The database is created with a name ' phpmysql '. Now we can create
a table inside the database.

To create a table, click on Go button to open the structure Window as


shown in the figure below :

Fig. 10.1c

Insert details of all the fields in the table as name_id, name and password
along with their respective data type and values. Id field is set as primary
key and auto increment for uniquely identifying in table.

Select the data type as per your requirement such as INT, VARCHAR,
DATE, BOOLEAN etc.

Click on the Save button to save the entered data. we have completed the
process of creating the database and the table.

You can also change the structure of the table by clicking on table name in
left of phpmyadmin as shown in the figure below :

Fig. 10.1d

10.2

What is SQL

Structure Query Language (SQL) is a computer language used to


communicate with databases. SQL consists of instructions that can be used to
retrieve and delete information from a database, and also to modify
information in a database. It consists of three major language components :
Data Definition Language (DDL), Data Manipulation Language (DML),
Data Control Language (DCL).

DDL is used to define a database. It includes clauses to create and eliminate


tables and views. This portion of the language is generally used by database
designers. DML is used to modify and manipulate data within a database. It
includes commands to update and insert data in a database, and select and
delete data from a database. DCL is used to control access of various users
to the database. It includes commands to specify users who are allowed to
access database objects, or restricted from accessing database objects.
There are many different versions of the SQL language. However, to be
compliant with the 'ANSI standard' , they all support at least the major
commands such as INSERT, UPDATE, DELETE, SELECT, WHERE in a
similar manner.
To build a web site which shows some data on browser from a database, you
need the following :

A server-side scripting language, like PHP or ASP.

An RDBMS database program ( i.e. MySQL, MS Access, SQL Server)

SQL

HTML / CSS

The Java Script / AJAX

CHAPTER 11
PROJECT PROFILE
11.1

Tools used for working in PHP


WAMP server

PHP Designer

Dreamweaver

WOW slider

CSS menu

WAMP Server :

Wamp Server is a Windows web development


environment. It allows you to create web applications with Apache2, PHP
and a MySQL database. Alongside this, PhpMyAdmin allows you to
manage easily your databases.

Fig. 11.1(a)

PHP MyAdmin :

PHP MyAdmin is a free software tool written in PHP,


intended to handle the administration of MySQL over the Web. PHP MyAdmin
supports a wide range of operations on MySQL, MariaDB and Drizzle.
Frequently used operations (managing databases, tables, columns, relations,
indexes, users, permissions, etc) can be performed via the user interface,
while you still have the ability to directly execute any SQL statement.

Fig. 11.1(b)

PHP Designer :

PHP Designer is a powerful and lightning fast PHP


IDE and PHP EDITOR - but it's also a full-featured HTML5 , CSS3 and
JavaScript editor boosted with features to increase your productivity -- for
both beginners and professional developers. PHP Designer assists you
with everything from editing, analyzing, debugging to publishing websites
powered by PHP, HTML5, CSS3 to JavaScript and other languages.

Fig. 11.1(c)

Dream Weaver :

WOW Slider :

It is a simple tool for creating tables. It provides a


great help in table creations such as form as it has in-built formattings. The
designer just needs to specify number of rows and columns, width and
height of the required table.

Slides make a web page look more attractive and lively.


This tool is provided to design slides of your choice.

CSS Menu :

This tool helps to design menu options which is an


important part of any web page. A designer can design horizontal and
vertical menu bar of different themes.

11.2

My Project

There are two end users for the CMS. The end users are the staff and the
students and other one is the administrator. Both user types can access the
website through Login ID.
College Management System synchronizes the working of all the departments.
It looks on all aspects of a college, its students, faculties, Departments, marks
and other co curricular activities.
The College Management Systems objectives is to provide a system to manage
a college. Without automation the management of the college has become an
unwieldy task. The end users day-to-day jobs of managing a college will be
simplified by a considerable amount through the automated system. The system
will be able to handle many services to take care of all the students as well as
staff in a quick manner. The system should be user appropriate, easy to use,
provide easy recovery of errors and have an overall end user high subjective
satisfaction.
There are various linked pages to this site so that the user can login , navigate
and download, upload and update according to its requirements.

Home page :
This is the home page or the master page of the site. This page contains all other
links of the site. Most important, this page contains a login panel which is further
subdivided into student, employee and admin.

Student panel : This page contains links to pages such as sign_up

page for new users who are not registered and login page for the already
registered users.

Student sign_up :
The users who are new or unregistered can fill up a simple form on the sign_up
page inorder to navigate freely through the site.

Student login :
The users who have already registered can enter the site through a simple login
process.

After login :
After the login process, the user enters a page where you can manage your
personal account, fill up few personal and academic details, upload your profile
picture, upload and download the required documents.

Download page :
The download page contains important documents which can be downloaded or
saved in the user's system itself.

Similarly, the Home page contains the links to the pages such as Employee login
and sign_up and Admin login and sign_up.

Employee panel : Here, the teaching and non-teaching staff can


sign_up, login and manage their account personally.

Employee sign_up :

Employee login :

Additionally, the Home page contains another link to a dynamic page which is
the Welcome page. This page consists of a brief introduction of the college,
the user can navigate and surf through the site and take a tour. The users can
also search for images and videos in the gallery of important events held in
the college such as convocations, annual functions and seminars.

CONCLUSION
The main scope of this project College Management System is to provide an
easy way to circulate all the functionalities of a college, and manipulate data and
information about administration, students and staff easily and also to manage
the task related to the college students/employees/administration and to reduce
time to searching of appropriate candidates in college view.
This report will be used by the software engineers constructing the CMS and the
system end users.The software engineers will use the SRS to fully understand
the expectations of this CMS to construct the appropriate software. The college
end users will be able to use this report as a test to see if the software
engineers will be constructing the system to their expectations. If it is not to their
expectations the end users can specify how it is not to their liking and the
software engineers will change the SRS to fit the end users needs.

The software product to be produced is a College Management System which


will automate the major college operations. These three subsystems functionality
will be described in detail in section 2-Overall Description.

College Management System synchronizes the working of all the departments. It


looks on all aspects of a college, its students, faculties, Departments, marks and
other co curricular activities. The College Management Systems objectives is
to provide a system to manage a college. Without automation the management

of the college has become an unwieldy task. The end users day-to-day jobs of
managing a college will be simplified by a considerable amount through the
automated system. The system will be able to handle many services to take care
of all the students as well as staff in a quick manner. The system should be user
appropriate, easy to use, provide easy recovery of errors and have an overall
end user high subjective satisfaction.

REFERENCES
Web Enabled Commercial Application Development Using HTML,DHTML
JAVASCRIPT,PERL,CGI by IVAN BAYROSS
Tata McGraw - Hill Edition The Complete Reference PHP 5.2 by
STEVEN HOLZNER

HP Booklet

Das könnte Ihnen auch gefallen