BCCA II Year IV Sem PHP & MySQL
Paper - IV: PHP & MySQL
UNIT- I: Getting Started With PHP- Basic HTML Syntax, Basic PHP Syntax, Using FTP,
Testing Your Scripts, Sending Text To The Browser, Using The PHP Manual, Sending HTML
To The Browser, Adding Comment To The Script, Basic Debugging Steps. Variables- What Are
Variables?, Variable Syntax, Types Of Variables, Variable Values, Understanding Quotation
Marks. HTML Forms And PHP- Creating A Simple Forms, Choosing A Form Data In PHP,
Displaying Errors, Error Reporting, Manually Sending Data To A Page. Using Numbers-
Creating The Forms, Performing Arithmetic, Formatting Numbers, Understanding Precedence,
Incrementing And Decrementing A Number, Creating Random Numbers.
UNIT- II Using Strings- Creating The HTML Forms, Concatenating Strings, Handling
Newlines, HTML And PHP, Encoding And Decoding Strings, Finding Substrings, Replacing
Parts Of A String. Control Structures- Creating The HTML Forms, The if Conditional, Validation
Functions, Using Else, More Operators, Using elseif, The Switch Conditional, The For Loop.
Using Arrays- What Is An Array, Creating An Array, Adding Items To An Array, Accessing An
Array From A Form.
UNIT- III Creating Web Applications- Creating Templates, Using External Files, Using
Constants, Working With The Date And Time, Handling HTML Forms With PHP, Making
Forms Sticky, Sending Email, Output Buffering, Manipulating HTTP Headers. Cookies And
Sessions- What Are Cookies?, Creating Cookies, Reading From Cookies, Adding Parameters To
Cookies, Deleting A Cookie, What Are Sessions?, Creating Session, Accessing Session
Variables, Deleting Session. Creating Functions- Creating And Using Simple Functions,
Creating And Calling Functions That Take Arguments, Setting Default Arguments Values,
Creating And Using Functions That Return A Value, Understanding Variable Scope.
UNIT- IV Files And Directories- File Permissions, Writing To Files, Locking To Files,
Reading From Files, Handling File Uploads, Navigating Directories, Creating Directories,
Reading Files Incrementally. Intro To Database- Introduction To SQL, Connecting To MYSQL,
MYSQL Error Handling, Creating And Selecting A Database, Creating A Database, Inserting
Data Into A Database, Securing Query Data, Retrieving Data From A Database, Deleting Data In
A Database, Updating Data In A Database. Putting It All Together- Getting Started, Connecting
To The Database, Writing The User-Defined Function, Creating The Template, Logging In,
Logging Out, Adding Quotes, Listing Quotes, Editing Quotes, Deleting Quotes, Creating The
Home Page.
Text Book
1. Larry Ullman, PHP for Web, Pearson.
Reference Books 1. Holznr, The Complete Reference – PHP,
McGraw-Hill.
2. Mike Mcgrath, PHP & MySQL in Easy Steps, McGraw-Hill.
3. Steve Suehring, Tim Converse & Joyce Park, PHP and MySQL,
Wiely.
4. Joel Murach & Ray Harris, murach‘s PHP and MySQL, Shroff
Publishers.
5. Jason Gilmore, Beginning PHP and MySQL.
,BCCA II Year IV Sem PHP & MySQL
Index
S.No. Unit Page No.
1 Introduction to PHP 3-14
2 HTML Forms and 15-27
Control Structures
3 Cookies, Functions & 28-37
Sessions
4 Introduction to 38-57
Database
,BCCA II Year IV Sem PHP & MySQL
Unit I
PHP - Introduction
• PHP started out as a small open source project that evolved as more and more people found out
how useful it was. Rasmus Lerdorf unleashed the first version of PHP way back in 1994.
• PHP: Hypertext Preprocessor.
• PHP is a server side scripting language that is embedded in HTML. It is used to manage
dynamic content, databases, session tracking, even build entire e-commerce sites.
• It is integrated with a number of popular databases, including MySQL, PostgreSQL, Oracle, Sybase,
Informix, and Microsoft SQL Server.
• PHP is pleasingly zippy in its execution, especially when compiled as an Apache module on the Unix
side. The MySQL server, once started, executes even very complex queries with huge result sets in
record-setting time.
• PHP supports a large number of major protocols such as POP3, IMAP, and LDAP.PHP4 added
support for Java and distributed object architectures (COM and CORBA), making n-tier development a
possibility for the first time.
• . PHP is forgiving: PHP language tries to be as forgiving as possible.
• PHP Syntax is like C.
Fornt end : programming lan. C C++ VB VB.net Java C# python
Data enter → taking input from the user → to make a information
Back end→ database→ Access,oracle,mysql
To store same type of data in bulk
Connectivity
Front end ---→ back end
Form filled -→ database
Front end → new from, recrods
|
|
Back end → according to user needs database provides the things
Common Uses of PHP
• PHP performs system functions, i.e. from files on a system it can create, open, read, write,and close
them.
• PHP can handle forms, i.e. gather data from files, save data to a file, through email send data, return
data to the user.
• . Add, delete, modify elements within your database through PHP.
• . Access cookies variables and set cookies.
• . Using PHP, you can restrict users to access some pages of your website.
• . It can encrypt data.
Script in PHP :
Start with simple PHP scripts "Hello, World!" is an example.PHP is embedded in HTML.
<html>
<head>
<title>Hello World</title>
<body>
<?php echo "Hello, World!";?>
</body>
, BCCA II Year IV Sem PHP & MySQL
PHP Syntax Overview
EscapingtoPHP :The PHP parsing engine needs a way to differentiate PHP code from other
elements in the page. The mechanism for doing so is known as 'escaping to PHP.' There are four
ways to do this:
Canonical PHP tags:The universally effective PHP tag style is:
<?php...?>
Short-open (SGML-style) tags :Short open tags :
<?...?>
ASP-style tags:ASP-style tags mimic the tags used by Active Server Pages to delineate code
blocks.
<%...%>
HTML script tags :
<script language="PHP">...</script>
Commenting PHP Code:
A comment is the portion of a program that exists only for the human reader and stripped
out before displaying the programs result. There are two commenting formats in PHP.
Single-line comments: They are generally used for short explanations or notes relevant
to the local code.
<?
# This is a comment, and
# This is the second line of the comment
// This is a comment too. Each style comments only
print "An example with single line comments";
?>
Multi-lines comments: They are generally used to provide pseudocode algorithms and
more detailed explanations when necessary. The multiline style of commenting is the same
as in C.
<?
/* This is a comment with multiline
Author : Mohammad Mohtashim
Purpose: Multiline Comments Demo
Subject: PHP
*/
print "An example with multi line comments";
?>
PHP white space insensitive:Whitespace is the stuff type that is typically invisible on
the screen, including spaces,tabs, and carriage returns (end-of-line characters).
PHP whitespace insensitive means that it almost never matters how many whitespace
characters you have in a row.one whitespace character is the same as many such
characters.
PHPiscasesensitive
PHP is a case sensitive language.
<html>
Paper - IV: PHP & MySQL
UNIT- I: Getting Started With PHP- Basic HTML Syntax, Basic PHP Syntax, Using FTP,
Testing Your Scripts, Sending Text To The Browser, Using The PHP Manual, Sending HTML
To The Browser, Adding Comment To The Script, Basic Debugging Steps. Variables- What Are
Variables?, Variable Syntax, Types Of Variables, Variable Values, Understanding Quotation
Marks. HTML Forms And PHP- Creating A Simple Forms, Choosing A Form Data In PHP,
Displaying Errors, Error Reporting, Manually Sending Data To A Page. Using Numbers-
Creating The Forms, Performing Arithmetic, Formatting Numbers, Understanding Precedence,
Incrementing And Decrementing A Number, Creating Random Numbers.
UNIT- II Using Strings- Creating The HTML Forms, Concatenating Strings, Handling
Newlines, HTML And PHP, Encoding And Decoding Strings, Finding Substrings, Replacing
Parts Of A String. Control Structures- Creating The HTML Forms, The if Conditional, Validation
Functions, Using Else, More Operators, Using elseif, The Switch Conditional, The For Loop.
Using Arrays- What Is An Array, Creating An Array, Adding Items To An Array, Accessing An
Array From A Form.
UNIT- III Creating Web Applications- Creating Templates, Using External Files, Using
Constants, Working With The Date And Time, Handling HTML Forms With PHP, Making
Forms Sticky, Sending Email, Output Buffering, Manipulating HTTP Headers. Cookies And
Sessions- What Are Cookies?, Creating Cookies, Reading From Cookies, Adding Parameters To
Cookies, Deleting A Cookie, What Are Sessions?, Creating Session, Accessing Session
Variables, Deleting Session. Creating Functions- Creating And Using Simple Functions,
Creating And Calling Functions That Take Arguments, Setting Default Arguments Values,
Creating And Using Functions That Return A Value, Understanding Variable Scope.
UNIT- IV Files And Directories- File Permissions, Writing To Files, Locking To Files,
Reading From Files, Handling File Uploads, Navigating Directories, Creating Directories,
Reading Files Incrementally. Intro To Database- Introduction To SQL, Connecting To MYSQL,
MYSQL Error Handling, Creating And Selecting A Database, Creating A Database, Inserting
Data Into A Database, Securing Query Data, Retrieving Data From A Database, Deleting Data In
A Database, Updating Data In A Database. Putting It All Together- Getting Started, Connecting
To The Database, Writing The User-Defined Function, Creating The Template, Logging In,
Logging Out, Adding Quotes, Listing Quotes, Editing Quotes, Deleting Quotes, Creating The
Home Page.
Text Book
1. Larry Ullman, PHP for Web, Pearson.
Reference Books 1. Holznr, The Complete Reference – PHP,
McGraw-Hill.
2. Mike Mcgrath, PHP & MySQL in Easy Steps, McGraw-Hill.
3. Steve Suehring, Tim Converse & Joyce Park, PHP and MySQL,
Wiely.
4. Joel Murach & Ray Harris, murach‘s PHP and MySQL, Shroff
Publishers.
5. Jason Gilmore, Beginning PHP and MySQL.
,BCCA II Year IV Sem PHP & MySQL
Index
S.No. Unit Page No.
1 Introduction to PHP 3-14
2 HTML Forms and 15-27
Control Structures
3 Cookies, Functions & 28-37
Sessions
4 Introduction to 38-57
Database
,BCCA II Year IV Sem PHP & MySQL
Unit I
PHP - Introduction
• PHP started out as a small open source project that evolved as more and more people found out
how useful it was. Rasmus Lerdorf unleashed the first version of PHP way back in 1994.
• PHP: Hypertext Preprocessor.
• PHP is a server side scripting language that is embedded in HTML. It is used to manage
dynamic content, databases, session tracking, even build entire e-commerce sites.
• It is integrated with a number of popular databases, including MySQL, PostgreSQL, Oracle, Sybase,
Informix, and Microsoft SQL Server.
• PHP is pleasingly zippy in its execution, especially when compiled as an Apache module on the Unix
side. The MySQL server, once started, executes even very complex queries with huge result sets in
record-setting time.
• PHP supports a large number of major protocols such as POP3, IMAP, and LDAP.PHP4 added
support for Java and distributed object architectures (COM and CORBA), making n-tier development a
possibility for the first time.
• . PHP is forgiving: PHP language tries to be as forgiving as possible.
• PHP Syntax is like C.
Fornt end : programming lan. C C++ VB VB.net Java C# python
Data enter → taking input from the user → to make a information
Back end→ database→ Access,oracle,mysql
To store same type of data in bulk
Connectivity
Front end ---→ back end
Form filled -→ database
Front end → new from, recrods
|
|
Back end → according to user needs database provides the things
Common Uses of PHP
• PHP performs system functions, i.e. from files on a system it can create, open, read, write,and close
them.
• PHP can handle forms, i.e. gather data from files, save data to a file, through email send data, return
data to the user.
• . Add, delete, modify elements within your database through PHP.
• . Access cookies variables and set cookies.
• . Using PHP, you can restrict users to access some pages of your website.
• . It can encrypt data.
Script in PHP :
Start with simple PHP scripts "Hello, World!" is an example.PHP is embedded in HTML.
<html>
<head>
<title>Hello World</title>
<body>
<?php echo "Hello, World!";?>
</body>
, BCCA II Year IV Sem PHP & MySQL
PHP Syntax Overview
EscapingtoPHP :The PHP parsing engine needs a way to differentiate PHP code from other
elements in the page. The mechanism for doing so is known as 'escaping to PHP.' There are four
ways to do this:
Canonical PHP tags:The universally effective PHP tag style is:
<?php...?>
Short-open (SGML-style) tags :Short open tags :
<?...?>
ASP-style tags:ASP-style tags mimic the tags used by Active Server Pages to delineate code
blocks.
<%...%>
HTML script tags :
<script language="PHP">...</script>
Commenting PHP Code:
A comment is the portion of a program that exists only for the human reader and stripped
out before displaying the programs result. There are two commenting formats in PHP.
Single-line comments: They are generally used for short explanations or notes relevant
to the local code.
<?
# This is a comment, and
# This is the second line of the comment
// This is a comment too. Each style comments only
print "An example with single line comments";
?>
Multi-lines comments: They are generally used to provide pseudocode algorithms and
more detailed explanations when necessary. The multiline style of commenting is the same
as in C.
<?
/* This is a comment with multiline
Author : Mohammad Mohtashim
Purpose: Multiline Comments Demo
Subject: PHP
*/
print "An example with multi line comments";
?>
PHP white space insensitive:Whitespace is the stuff type that is typically invisible on
the screen, including spaces,tabs, and carriage returns (end-of-line characters).
PHP whitespace insensitive means that it almost never matters how many whitespace
characters you have in a row.one whitespace character is the same as many such
characters.
PHPiscasesensitive
PHP is a case sensitive language.
<html>