SlideShare a Scribd company logo
UNIT - 5
WEB APPLICATION, COOKIES AND SESSIONS
Sending email
• Syntax: mail(to, subject, body, [headers]);
• Eg:
$to = 'email@example.com';
$subject = 'This is the subject';
$body = 'This is the body. It goes over multiple lines.';
mail ($to, $subject, $body);
• Subject line cannot include ‘n’.
• Body should not exceed 70 characters.
$body = wordwrap($body, 70);
Example
Handling file uploads
• Steps
• Things to be considered:
• PHP- correct settings
• Temporary storage directory
• Final storage directory
• Allowing for file uploads:
php.ini
• Uploading files with PHP:
<form enctype="multipart/form-data" action="script.php"
method="post">
<input type="hidden" name="MAX_FILE_SIZE" value="30000" />
File <input type="file" name= "upload" />
• $_FILES: name, type, size, tmp_name, error.
• move_uploaded_file (temporary
_filename,/path/to/destination/filename);
Example
PHP and Javascript
• Javascript with HTML code can be done in 2 ways:
• Inline
• External file
• Inline Javascript
<script type="text/javascript">
// A c t u a l J a v a S c r i p t c o d e.
</script>
• External Javascript
<script type="text/javascript" src="somefile.js"></script>
Comparison
JAVASCRIPT PHP
Client side program Server side program
Can detect the size of popup, browser window and
image mouse over
Cannot detect
Cannot interact with MySQL Can interact with MySQL
Cannot generate PHP code Can dynamically generate Javascript
.js .php
OOP approach Procedural and OOP approach
In HTML: <script type=“text/javascript”>
</script>
<?php
?>
Understanding HTTP headers
• the uploaded images are being stored in the ‘uploads’ directory.
• the images cannot be viewed directly in the Web browser using either
of the following:
http://www.example.com/uploads/ image.png or
<img src="image.png" />
• create a proxy script in PHP.
http://www.example.com/proxy.php? image=image.png
or
<img src="proxy.php?image=image.png" />
Proxy script
Header()
• used to redirect the Web browser from the current page to another.
• syntax: header(header string);
• header ('Location: http://www.example.com/page.php’);
• To send a file:
header("Content-Type:application/pdfn");
header ("Content-Disposition: attachment;
filename="somefile.pdf"n");
header ("Content-Length: 4096n");
Date and time function
• Date_default_timezone_set(tz);
• Checkdate();
• Date(format, [timestamp]);
Date() function
formatting
• Eg:
echo date('F j, Y'); // January 26, 2011
echo date('H:i'); // 23:14
echo date('D'); // Sat
• mktime(): mktime (hour, minute, second, month, day, year);
• getdate():
$today = getdate( );
echo $today['month']; // October
getdate() array
Making a Login page
Making the login functions
• header ('Location: http://www. example.com/page.php');
exit( );
• 3 step process:
• Email address
• Password
• Email address and password
Using cookies
• a way for a server to store information on the user’s machine.
Setting cookies
• Setcookie(name, value, expiration, path, host, secure, httponly);
Accessing cookies
Deleting cookies
Session
• Data stored on the server.
• Advantages of session over cookies:
• Secure
• More data
• Without cookies
• Advantages of cookies over session:
• Easier
• Less of server
• More time
Setting the session
• Session_start()
• Accessing the session: $_SESSION
• Deleting the session:
• Unset($_SESSION[‘var’]);
• $_SESSION=array();
• Session_destroy();
Improving session security
• Session ID and session data
• HTTP_USER_AGENT
$_SESSION[‘agent’]=md5($_SERVER[‘HTTP_USER_AGENT’]);

More Related Content

What's hot

MongoDB at RubyEnRails 2009
MongoDB at RubyEnRails 2009MongoDB at RubyEnRails 2009
MongoDB at RubyEnRails 2009
Mike Dirolf
 
WordCamp Ann Arbor 2015 Introduction to Backbone + WP REST API
WordCamp Ann Arbor 2015 Introduction to Backbone + WP REST APIWordCamp Ann Arbor 2015 Introduction to Backbone + WP REST API
WordCamp Ann Arbor 2015 Introduction to Backbone + WP REST API
Brian Hogg
 
So You Want to Build and Release a Plugin? WordCamp Lancaster 2014
So You Want to Build and Release a Plugin? WordCamp Lancaster 2014So You Want to Build and Release a Plugin? WordCamp Lancaster 2014
So You Want to Build and Release a Plugin? WordCamp Lancaster 2014
ryanduff
 
Extending Custom Post Types
Extending Custom Post Types Extending Custom Post Types
Extending Custom Post Types
ryanduff
 
Amp and higher computing science
Amp and higher computing scienceAmp and higher computing science
Amp and higher computing science
Charlie Love
 
4Developers: Michał Papis- Publikowanie gemów
4Developers: Michał Papis- Publikowanie gemów4Developers: Michał Papis- Publikowanie gemów
4Developers: Michał Papis- Publikowanie gemów
PROIDEA
 
Ppt php
Ppt phpPpt php
Php converted pdf
Php converted pdfPhp converted pdf
Php converted pdf
Northpole Web Service
 
Webinar: Getting Started with Ruby and MongoDB
Webinar: Getting Started with Ruby and MongoDBWebinar: Getting Started with Ruby and MongoDB
Webinar: Getting Started with Ruby and MongoDB
MongoDB
 
Getting Started with WP-CLI, a tool to automate your life
Getting Started with WP-CLI, a tool to automate your lifeGetting Started with WP-CLI, a tool to automate your life
Getting Started with WP-CLI, a tool to automate your life
AJ Morris
 
Modern Perl Web Development with Dancer
Modern Perl Web Development with DancerModern Perl Web Development with Dancer
Modern Perl Web Development with Dancer
Dave Cross
 
Php File Upload
Php File UploadPhp File Upload
Php File Upload
Hiroaki Kawai
 
Type URL, Enter, and Then …
Type URL, Enter, and Then …Type URL, Enter, and Then …
Type URL, Enter, and Then …
Jinglun Li
 
php (Hypertext Preprocessor)
php (Hypertext Preprocessor)php (Hypertext Preprocessor)
php (Hypertext Preprocessor)
Chandan Das
 
Express Presentation
Express PresentationExpress Presentation
Express Presentation
aaronheckmann
 
CouchDB for Web Applications - Erlang Factory London 2009
CouchDB for Web Applications - Erlang Factory London 2009CouchDB for Web Applications - Erlang Factory London 2009
CouchDB for Web Applications - Erlang Factory London 2009
Jason Davies
 

What's hot (17)

MongoDB at RubyEnRails 2009
MongoDB at RubyEnRails 2009MongoDB at RubyEnRails 2009
MongoDB at RubyEnRails 2009
 
WordCamp Ann Arbor 2015 Introduction to Backbone + WP REST API
WordCamp Ann Arbor 2015 Introduction to Backbone + WP REST APIWordCamp Ann Arbor 2015 Introduction to Backbone + WP REST API
WordCamp Ann Arbor 2015 Introduction to Backbone + WP REST API
 
So You Want to Build and Release a Plugin? WordCamp Lancaster 2014
So You Want to Build and Release a Plugin? WordCamp Lancaster 2014So You Want to Build and Release a Plugin? WordCamp Lancaster 2014
So You Want to Build and Release a Plugin? WordCamp Lancaster 2014
 
Extending Custom Post Types
Extending Custom Post Types Extending Custom Post Types
Extending Custom Post Types
 
Amp and higher computing science
Amp and higher computing scienceAmp and higher computing science
Amp and higher computing science
 
4Developers: Michał Papis- Publikowanie gemów
4Developers: Michał Papis- Publikowanie gemów4Developers: Michał Papis- Publikowanie gemów
4Developers: Michał Papis- Publikowanie gemów
 
Ppt php
Ppt phpPpt php
Ppt php
 
Php converted pdf
Php converted pdfPhp converted pdf
Php converted pdf
 
Webinar: Getting Started with Ruby and MongoDB
Webinar: Getting Started with Ruby and MongoDBWebinar: Getting Started with Ruby and MongoDB
Webinar: Getting Started with Ruby and MongoDB
 
Getting Started with WP-CLI, a tool to automate your life
Getting Started with WP-CLI, a tool to automate your lifeGetting Started with WP-CLI, a tool to automate your life
Getting Started with WP-CLI, a tool to automate your life
 
Modern Perl Web Development with Dancer
Modern Perl Web Development with DancerModern Perl Web Development with Dancer
Modern Perl Web Development with Dancer
 
Php File Upload
Php File UploadPhp File Upload
Php File Upload
 
Type URL, Enter, and Then …
Type URL, Enter, and Then …Type URL, Enter, and Then …
Type URL, Enter, and Then …
 
php (Hypertext Preprocessor)
php (Hypertext Preprocessor)php (Hypertext Preprocessor)
php (Hypertext Preprocessor)
 
Express Presentation
Express PresentationExpress Presentation
Express Presentation
 
CouchDB for Web Applications - Erlang Factory London 2009
CouchDB for Web Applications - Erlang Factory London 2009CouchDB for Web Applications - Erlang Factory London 2009
CouchDB for Web Applications - Erlang Factory London 2009
 
Nanoc
NanocNanoc
Nanoc
 

Similar to Web application, cookies and sessions

Real World Seaside Applications
Real World Seaside ApplicationsReal World Seaside Applications
Real World Seaside Applications
ESUG
 
Php file upload, cookies & session
Php file upload, cookies & sessionPhp file upload, cookies & session
Php file upload, cookies & sessionJamshid Hashimi
 
Expert guide for PHP
Expert guide for PHPExpert guide for PHP
Expert guide for PHP
Steve Fort
 
Secure PHP Coding - Part 1
Secure PHP Coding - Part 1Secure PHP Coding - Part 1
Secure PHP Coding - Part 1
Vinoth Kumar
 
Bypass file upload restrictions
Bypass file upload restrictionsBypass file upload restrictions
Bypass file upload restrictions
Mukesh k.r
 
Extending WordPress
Extending WordPressExtending WordPress
Extending WordPress
Jonathan Bossenger
 
PHP language presentation
PHP language presentationPHP language presentation
PHP language presentation
Annujj Agrawaal
 
Node JS Core Module PowerPoint Presentation
Node JS Core Module PowerPoint PresentationNode JS Core Module PowerPoint Presentation
Node JS Core Module PowerPoint Presentation
rajeshkannan750222
 
Flask intro - ROSEdu web workshops
Flask intro - ROSEdu web workshopsFlask intro - ROSEdu web workshops
Flask intro - ROSEdu web workshops
Alex Eftimie
 
File upload php
File upload phpFile upload php
File upload php
sana mateen
 
Boost your website by running PHP on Nginx
Boost your website by running PHP on NginxBoost your website by running PHP on Nginx
Boost your website by running PHP on Nginx
Harald Zeitlhofer
 
Mobile themes, QR codes, and shortURLs
Mobile themes, QR codes, and shortURLsMobile themes, QR codes, and shortURLs
Mobile themes, QR codes, and shortURLs
Harvard Web Working Group
 
An Introduction to Tornado
An Introduction to TornadoAn Introduction to Tornado
An Introduction to TornadoGavin Roy
 
Progressive downloads and rendering (Stoyan Stefanov)
Progressive downloads and rendering (Stoyan Stefanov)Progressive downloads and rendering (Stoyan Stefanov)
Progressive downloads and rendering (Stoyan Stefanov)Ontico
 
JavaScript performance patterns
JavaScript performance patternsJavaScript performance patterns
JavaScript performance patterns
Stoyan Stefanov
 

Similar to Web application, cookies and sessions (20)

Introduction to php web programming - get and post
Introduction to php  web programming - get and postIntroduction to php  web programming - get and post
Introduction to php web programming - get and post
 
bcgr3-jquery
bcgr3-jquerybcgr3-jquery
bcgr3-jquery
 
bcgr3-jquery
bcgr3-jquerybcgr3-jquery
bcgr3-jquery
 
Real World Seaside Applications
Real World Seaside ApplicationsReal World Seaside Applications
Real World Seaside Applications
 
Php file upload, cookies & session
Php file upload, cookies & sessionPhp file upload, cookies & session
Php file upload, cookies & session
 
Expert guide for PHP
Expert guide for PHPExpert guide for PHP
Expert guide for PHP
 
Seven deadly theming sins
Seven deadly theming sinsSeven deadly theming sins
Seven deadly theming sins
 
Secure PHP Coding - Part 1
Secure PHP Coding - Part 1Secure PHP Coding - Part 1
Secure PHP Coding - Part 1
 
Bypass file upload restrictions
Bypass file upload restrictionsBypass file upload restrictions
Bypass file upload restrictions
 
Extending WordPress
Extending WordPressExtending WordPress
Extending WordPress
 
PHP language presentation
PHP language presentationPHP language presentation
PHP language presentation
 
PHP and MySQL
PHP and MySQLPHP and MySQL
PHP and MySQL
 
Node JS Core Module PowerPoint Presentation
Node JS Core Module PowerPoint PresentationNode JS Core Module PowerPoint Presentation
Node JS Core Module PowerPoint Presentation
 
Flask intro - ROSEdu web workshops
Flask intro - ROSEdu web workshopsFlask intro - ROSEdu web workshops
Flask intro - ROSEdu web workshops
 
File upload php
File upload phpFile upload php
File upload php
 
Boost your website by running PHP on Nginx
Boost your website by running PHP on NginxBoost your website by running PHP on Nginx
Boost your website by running PHP on Nginx
 
Mobile themes, QR codes, and shortURLs
Mobile themes, QR codes, and shortURLsMobile themes, QR codes, and shortURLs
Mobile themes, QR codes, and shortURLs
 
An Introduction to Tornado
An Introduction to TornadoAn Introduction to Tornado
An Introduction to Tornado
 
Progressive downloads and rendering (Stoyan Stefanov)
Progressive downloads and rendering (Stoyan Stefanov)Progressive downloads and rendering (Stoyan Stefanov)
Progressive downloads and rendering (Stoyan Stefanov)
 
JavaScript performance patterns
JavaScript performance patternsJavaScript performance patterns
JavaScript performance patterns
 

More from hamsa nandhini

SOA - Unit 5 - SOA and Business Process Management
SOA - Unit   5 - SOA and Business Process ManagementSOA - Unit   5 - SOA and Business Process Management
SOA - Unit 5 - SOA and Business Process Management
hamsa nandhini
 
SOA - Unit 4 - SOA & Web Services for integration and Multi-Channel access
SOA - Unit   4 - SOA & Web Services for integration and Multi-Channel accessSOA - Unit   4 - SOA & Web Services for integration and Multi-Channel access
SOA - Unit 4 - SOA & Web Services for integration and Multi-Channel access
hamsa nandhini
 
SOA - Unit 3 - SOA and Web Services
SOA - Unit   3 - SOA and Web ServicesSOA - Unit   3 - SOA and Web Services
SOA - Unit 3 - SOA and Web Services
hamsa nandhini
 
SOA - Unit 2 - Service Oriented Architecture
SOA - Unit   2 - Service Oriented ArchitectureSOA - Unit   2 - Service Oriented Architecture
SOA - Unit 2 - Service Oriented Architecture
hamsa nandhini
 
SOA - Unit 1 - Introduction to SOA with Web Services
SOA - Unit   1 - Introduction to SOA with Web ServicesSOA - Unit   1 - Introduction to SOA with Web Services
SOA - Unit 1 - Introduction to SOA with Web Services
hamsa nandhini
 
NP - Unit 5 - Bootstrap, Autoconfigurion and BGP
NP - Unit 5 - Bootstrap, Autoconfigurion and BGPNP - Unit 5 - Bootstrap, Autoconfigurion and BGP
NP - Unit 5 - Bootstrap, Autoconfigurion and BGP
hamsa nandhini
 
NP - Unit 4 - Routing - RIP, OSPF and Internet Multicasting
NP - Unit 4 - Routing - RIP, OSPF and Internet MulticastingNP - Unit 4 - Routing - RIP, OSPF and Internet Multicasting
NP - Unit 4 - Routing - RIP, OSPF and Internet Multicasting
hamsa nandhini
 
NP - Unit 3 - Forwarding Datagram and ICMP
NP - Unit 3 - Forwarding Datagram and ICMPNP - Unit 3 - Forwarding Datagram and ICMP
NP - Unit 3 - Forwarding Datagram and ICMP
hamsa nandhini
 
NP - Unit 2 - Internet Addressing, ARP and RARP
NP - Unit 2 - Internet Addressing, ARP and RARP NP - Unit 2 - Internet Addressing, ARP and RARP
NP - Unit 2 - Internet Addressing, ARP and RARP
hamsa nandhini
 
Unit 1
Unit 1Unit 1
PHP with MySQL
PHP with MySQLPHP with MySQL
PHP with MySQL
hamsa nandhini
 
Database design and error handling
Database design and error handlingDatabase design and error handling
Database design and error handling
hamsa nandhini
 
Introduction to MySQL in PHP
Introduction to MySQL in PHPIntroduction to MySQL in PHP
Introduction to MySQL in PHP
hamsa nandhini
 
Basics of PHP
Basics of PHPBasics of PHP
Basics of PHP
hamsa nandhini
 
XML Security
XML SecurityXML Security
XML Security
hamsa nandhini
 
SOAP and Web services
SOAP and Web servicesSOAP and Web services
SOAP and Web services
hamsa nandhini
 
XML Technologies
XML TechnologiesXML Technologies
XML Technologies
hamsa nandhini
 
XML DTD and Schema
XML DTD and SchemaXML DTD and Schema
XML DTD and Schema
hamsa nandhini
 
fundamentals of XML
fundamentals of XMLfundamentals of XML
fundamentals of XML
hamsa nandhini
 

More from hamsa nandhini (19)

SOA - Unit 5 - SOA and Business Process Management
SOA - Unit   5 - SOA and Business Process ManagementSOA - Unit   5 - SOA and Business Process Management
SOA - Unit 5 - SOA and Business Process Management
 
SOA - Unit 4 - SOA & Web Services for integration and Multi-Channel access
SOA - Unit   4 - SOA & Web Services for integration and Multi-Channel accessSOA - Unit   4 - SOA & Web Services for integration and Multi-Channel access
SOA - Unit 4 - SOA & Web Services for integration and Multi-Channel access
 
SOA - Unit 3 - SOA and Web Services
SOA - Unit   3 - SOA and Web ServicesSOA - Unit   3 - SOA and Web Services
SOA - Unit 3 - SOA and Web Services
 
SOA - Unit 2 - Service Oriented Architecture
SOA - Unit   2 - Service Oriented ArchitectureSOA - Unit   2 - Service Oriented Architecture
SOA - Unit 2 - Service Oriented Architecture
 
SOA - Unit 1 - Introduction to SOA with Web Services
SOA - Unit   1 - Introduction to SOA with Web ServicesSOA - Unit   1 - Introduction to SOA with Web Services
SOA - Unit 1 - Introduction to SOA with Web Services
 
NP - Unit 5 - Bootstrap, Autoconfigurion and BGP
NP - Unit 5 - Bootstrap, Autoconfigurion and BGPNP - Unit 5 - Bootstrap, Autoconfigurion and BGP
NP - Unit 5 - Bootstrap, Autoconfigurion and BGP
 
NP - Unit 4 - Routing - RIP, OSPF and Internet Multicasting
NP - Unit 4 - Routing - RIP, OSPF and Internet MulticastingNP - Unit 4 - Routing - RIP, OSPF and Internet Multicasting
NP - Unit 4 - Routing - RIP, OSPF and Internet Multicasting
 
NP - Unit 3 - Forwarding Datagram and ICMP
NP - Unit 3 - Forwarding Datagram and ICMPNP - Unit 3 - Forwarding Datagram and ICMP
NP - Unit 3 - Forwarding Datagram and ICMP
 
NP - Unit 2 - Internet Addressing, ARP and RARP
NP - Unit 2 - Internet Addressing, ARP and RARP NP - Unit 2 - Internet Addressing, ARP and RARP
NP - Unit 2 - Internet Addressing, ARP and RARP
 
Unit 1
Unit 1Unit 1
Unit 1
 
PHP with MySQL
PHP with MySQLPHP with MySQL
PHP with MySQL
 
Database design and error handling
Database design and error handlingDatabase design and error handling
Database design and error handling
 
Introduction to MySQL in PHP
Introduction to MySQL in PHPIntroduction to MySQL in PHP
Introduction to MySQL in PHP
 
Basics of PHP
Basics of PHPBasics of PHP
Basics of PHP
 
XML Security
XML SecurityXML Security
XML Security
 
SOAP and Web services
SOAP and Web servicesSOAP and Web services
SOAP and Web services
 
XML Technologies
XML TechnologiesXML Technologies
XML Technologies
 
XML DTD and Schema
XML DTD and SchemaXML DTD and Schema
XML DTD and Schema
 
fundamentals of XML
fundamentals of XMLfundamentals of XML
fundamentals of XML
 

Recently uploaded

AP LAB PPT.pdf ap lab ppt no title specific
AP LAB PPT.pdf ap lab ppt no title specificAP LAB PPT.pdf ap lab ppt no title specific
AP LAB PPT.pdf ap lab ppt no title specific
BrazilAccount1
 
English lab ppt no titlespecENG PPTt.pdf
English lab ppt no titlespecENG PPTt.pdfEnglish lab ppt no titlespecENG PPTt.pdf
English lab ppt no titlespecENG PPTt.pdf
BrazilAccount1
 
一比一原版(UofT毕业证)多伦多大学毕业证成绩单如何办理
一比一原版(UofT毕业证)多伦多大学毕业证成绩单如何办理一比一原版(UofT毕业证)多伦多大学毕业证成绩单如何办理
一比一原版(UofT毕业证)多伦多大学毕业证成绩单如何办理
ydteq
 
CME397 Surface Engineering- Professional Elective
CME397 Surface Engineering- Professional ElectiveCME397 Surface Engineering- Professional Elective
CME397 Surface Engineering- Professional Elective
karthi keyan
 
Top 10 Oil and Gas Projects in Saudi Arabia 2024.pdf
Top 10 Oil and Gas Projects in Saudi Arabia 2024.pdfTop 10 Oil and Gas Projects in Saudi Arabia 2024.pdf
Top 10 Oil and Gas Projects in Saudi Arabia 2024.pdf
Teleport Manpower Consultant
 
Water Industry Process Automation and Control Monthly - May 2024.pdf
Water Industry Process Automation and Control Monthly - May 2024.pdfWater Industry Process Automation and Control Monthly - May 2024.pdf
Water Industry Process Automation and Control Monthly - May 2024.pdf
Water Industry Process Automation & Control
 
Hybrid optimization of pumped hydro system and solar- Engr. Abdul-Azeez.pdf
Hybrid optimization of pumped hydro system and solar- Engr. Abdul-Azeez.pdfHybrid optimization of pumped hydro system and solar- Engr. Abdul-Azeez.pdf
Hybrid optimization of pumped hydro system and solar- Engr. Abdul-Azeez.pdf
fxintegritypublishin
 
Gen AI Study Jams _ For the GDSC Leads in India.pdf
Gen AI Study Jams _ For the GDSC Leads in India.pdfGen AI Study Jams _ For the GDSC Leads in India.pdf
Gen AI Study Jams _ For the GDSC Leads in India.pdf
gdsczhcet
 
space technology lecture notes on satellite
space technology lecture notes on satellitespace technology lecture notes on satellite
space technology lecture notes on satellite
ongomchris
 
ML for identifying fraud using open blockchain data.pptx
ML for identifying fraud using open blockchain data.pptxML for identifying fraud using open blockchain data.pptx
ML for identifying fraud using open blockchain data.pptx
Vijay Dialani, PhD
 
在线办理(ANU毕业证书)澳洲国立大学毕业证录取通知书一模一样
在线办理(ANU毕业证书)澳洲国立大学毕业证录取通知书一模一样在线办理(ANU毕业证书)澳洲国立大学毕业证录取通知书一模一样
在线办理(ANU毕业证书)澳洲国立大学毕业证录取通知书一模一样
obonagu
 
Cosmetic shop management system project report.pdf
Cosmetic shop management system project report.pdfCosmetic shop management system project report.pdf
Cosmetic shop management system project report.pdf
Kamal Acharya
 
power quality voltage fluctuation UNIT - I.pptx
power quality voltage fluctuation UNIT - I.pptxpower quality voltage fluctuation UNIT - I.pptx
power quality voltage fluctuation UNIT - I.pptx
ViniHema
 
Hierarchical Digital Twin of a Naval Power System
Hierarchical Digital Twin of a Naval Power SystemHierarchical Digital Twin of a Naval Power System
Hierarchical Digital Twin of a Naval Power System
Kerry Sado
 
weather web application report.pdf
weather web application report.pdfweather web application report.pdf
weather web application report.pdf
Pratik Pawar
 
AKS UNIVERSITY Satna Final Year Project By OM Hardaha.pdf
AKS UNIVERSITY Satna Final Year Project By OM Hardaha.pdfAKS UNIVERSITY Satna Final Year Project By OM Hardaha.pdf
AKS UNIVERSITY Satna Final Year Project By OM Hardaha.pdf
SamSarthak3
 
The Benefits and Techniques of Trenchless Pipe Repair.pdf
The Benefits and Techniques of Trenchless Pipe Repair.pdfThe Benefits and Techniques of Trenchless Pipe Repair.pdf
The Benefits and Techniques of Trenchless Pipe Repair.pdf
Pipe Restoration Solutions
 
一比一原版(IIT毕业证)伊利诺伊理工大学毕业证成绩单专业办理
一比一原版(IIT毕业证)伊利诺伊理工大学毕业证成绩单专业办理一比一原版(IIT毕业证)伊利诺伊理工大学毕业证成绩单专业办理
一比一原版(IIT毕业证)伊利诺伊理工大学毕业证成绩单专业办理
zwunae
 
Sachpazis:Terzaghi Bearing Capacity Estimation in simple terms with Calculati...
Sachpazis:Terzaghi Bearing Capacity Estimation in simple terms with Calculati...Sachpazis:Terzaghi Bearing Capacity Estimation in simple terms with Calculati...
Sachpazis:Terzaghi Bearing Capacity Estimation in simple terms with Calculati...
Dr.Costas Sachpazis
 
Runway Orientation Based on the Wind Rose Diagram.pptx
Runway Orientation Based on the Wind Rose Diagram.pptxRunway Orientation Based on the Wind Rose Diagram.pptx
Runway Orientation Based on the Wind Rose Diagram.pptx
SupreethSP4
 

Recently uploaded (20)

AP LAB PPT.pdf ap lab ppt no title specific
AP LAB PPT.pdf ap lab ppt no title specificAP LAB PPT.pdf ap lab ppt no title specific
AP LAB PPT.pdf ap lab ppt no title specific
 
English lab ppt no titlespecENG PPTt.pdf
English lab ppt no titlespecENG PPTt.pdfEnglish lab ppt no titlespecENG PPTt.pdf
English lab ppt no titlespecENG PPTt.pdf
 
一比一原版(UofT毕业证)多伦多大学毕业证成绩单如何办理
一比一原版(UofT毕业证)多伦多大学毕业证成绩单如何办理一比一原版(UofT毕业证)多伦多大学毕业证成绩单如何办理
一比一原版(UofT毕业证)多伦多大学毕业证成绩单如何办理
 
CME397 Surface Engineering- Professional Elective
CME397 Surface Engineering- Professional ElectiveCME397 Surface Engineering- Professional Elective
CME397 Surface Engineering- Professional Elective
 
Top 10 Oil and Gas Projects in Saudi Arabia 2024.pdf
Top 10 Oil and Gas Projects in Saudi Arabia 2024.pdfTop 10 Oil and Gas Projects in Saudi Arabia 2024.pdf
Top 10 Oil and Gas Projects in Saudi Arabia 2024.pdf
 
Water Industry Process Automation and Control Monthly - May 2024.pdf
Water Industry Process Automation and Control Monthly - May 2024.pdfWater Industry Process Automation and Control Monthly - May 2024.pdf
Water Industry Process Automation and Control Monthly - May 2024.pdf
 
Hybrid optimization of pumped hydro system and solar- Engr. Abdul-Azeez.pdf
Hybrid optimization of pumped hydro system and solar- Engr. Abdul-Azeez.pdfHybrid optimization of pumped hydro system and solar- Engr. Abdul-Azeez.pdf
Hybrid optimization of pumped hydro system and solar- Engr. Abdul-Azeez.pdf
 
Gen AI Study Jams _ For the GDSC Leads in India.pdf
Gen AI Study Jams _ For the GDSC Leads in India.pdfGen AI Study Jams _ For the GDSC Leads in India.pdf
Gen AI Study Jams _ For the GDSC Leads in India.pdf
 
space technology lecture notes on satellite
space technology lecture notes on satellitespace technology lecture notes on satellite
space technology lecture notes on satellite
 
ML for identifying fraud using open blockchain data.pptx
ML for identifying fraud using open blockchain data.pptxML for identifying fraud using open blockchain data.pptx
ML for identifying fraud using open blockchain data.pptx
 
在线办理(ANU毕业证书)澳洲国立大学毕业证录取通知书一模一样
在线办理(ANU毕业证书)澳洲国立大学毕业证录取通知书一模一样在线办理(ANU毕业证书)澳洲国立大学毕业证录取通知书一模一样
在线办理(ANU毕业证书)澳洲国立大学毕业证录取通知书一模一样
 
Cosmetic shop management system project report.pdf
Cosmetic shop management system project report.pdfCosmetic shop management system project report.pdf
Cosmetic shop management system project report.pdf
 
power quality voltage fluctuation UNIT - I.pptx
power quality voltage fluctuation UNIT - I.pptxpower quality voltage fluctuation UNIT - I.pptx
power quality voltage fluctuation UNIT - I.pptx
 
Hierarchical Digital Twin of a Naval Power System
Hierarchical Digital Twin of a Naval Power SystemHierarchical Digital Twin of a Naval Power System
Hierarchical Digital Twin of a Naval Power System
 
weather web application report.pdf
weather web application report.pdfweather web application report.pdf
weather web application report.pdf
 
AKS UNIVERSITY Satna Final Year Project By OM Hardaha.pdf
AKS UNIVERSITY Satna Final Year Project By OM Hardaha.pdfAKS UNIVERSITY Satna Final Year Project By OM Hardaha.pdf
AKS UNIVERSITY Satna Final Year Project By OM Hardaha.pdf
 
The Benefits and Techniques of Trenchless Pipe Repair.pdf
The Benefits and Techniques of Trenchless Pipe Repair.pdfThe Benefits and Techniques of Trenchless Pipe Repair.pdf
The Benefits and Techniques of Trenchless Pipe Repair.pdf
 
一比一原版(IIT毕业证)伊利诺伊理工大学毕业证成绩单专业办理
一比一原版(IIT毕业证)伊利诺伊理工大学毕业证成绩单专业办理一比一原版(IIT毕业证)伊利诺伊理工大学毕业证成绩单专业办理
一比一原版(IIT毕业证)伊利诺伊理工大学毕业证成绩单专业办理
 
Sachpazis:Terzaghi Bearing Capacity Estimation in simple terms with Calculati...
Sachpazis:Terzaghi Bearing Capacity Estimation in simple terms with Calculati...Sachpazis:Terzaghi Bearing Capacity Estimation in simple terms with Calculati...
Sachpazis:Terzaghi Bearing Capacity Estimation in simple terms with Calculati...
 
Runway Orientation Based on the Wind Rose Diagram.pptx
Runway Orientation Based on the Wind Rose Diagram.pptxRunway Orientation Based on the Wind Rose Diagram.pptx
Runway Orientation Based on the Wind Rose Diagram.pptx
 

Web application, cookies and sessions

  • 1. UNIT - 5 WEB APPLICATION, COOKIES AND SESSIONS
  • 2. Sending email • Syntax: mail(to, subject, body, [headers]); • Eg: $to = 'email@example.com'; $subject = 'This is the subject'; $body = 'This is the body. It goes over multiple lines.'; mail ($to, $subject, $body); • Subject line cannot include ‘n’. • Body should not exceed 70 characters. $body = wordwrap($body, 70);
  • 4. Handling file uploads • Steps • Things to be considered: • PHP- correct settings • Temporary storage directory • Final storage directory • Allowing for file uploads: php.ini
  • 5. • Uploading files with PHP: <form enctype="multipart/form-data" action="script.php" method="post"> <input type="hidden" name="MAX_FILE_SIZE" value="30000" /> File <input type="file" name= "upload" /> • $_FILES: name, type, size, tmp_name, error. • move_uploaded_file (temporary _filename,/path/to/destination/filename);
  • 7. PHP and Javascript • Javascript with HTML code can be done in 2 ways: • Inline • External file • Inline Javascript <script type="text/javascript"> // A c t u a l J a v a S c r i p t c o d e. </script> • External Javascript <script type="text/javascript" src="somefile.js"></script>
  • 8. Comparison JAVASCRIPT PHP Client side program Server side program Can detect the size of popup, browser window and image mouse over Cannot detect Cannot interact with MySQL Can interact with MySQL Cannot generate PHP code Can dynamically generate Javascript .js .php OOP approach Procedural and OOP approach In HTML: <script type=“text/javascript”> </script> <?php ?>
  • 9. Understanding HTTP headers • the uploaded images are being stored in the ‘uploads’ directory. • the images cannot be viewed directly in the Web browser using either of the following: http://www.example.com/uploads/ image.png or <img src="image.png" /> • create a proxy script in PHP. http://www.example.com/proxy.php? image=image.png or <img src="proxy.php?image=image.png" />
  • 11. Header() • used to redirect the Web browser from the current page to another. • syntax: header(header string); • header ('Location: http://www.example.com/page.php’); • To send a file: header("Content-Type:application/pdfn"); header ("Content-Disposition: attachment; filename="somefile.pdf"n"); header ("Content-Length: 4096n");
  • 12. Date and time function • Date_default_timezone_set(tz); • Checkdate(); • Date(format, [timestamp]);
  • 14. • Eg: echo date('F j, Y'); // January 26, 2011 echo date('H:i'); // 23:14 echo date('D'); // Sat • mktime(): mktime (hour, minute, second, month, day, year); • getdate(): $today = getdate( ); echo $today['month']; // October
  • 17. Making the login functions • header ('Location: http://www. example.com/page.php'); exit( ); • 3 step process: • Email address • Password • Email address and password
  • 18. Using cookies • a way for a server to store information on the user’s machine.
  • 19. Setting cookies • Setcookie(name, value, expiration, path, host, secure, httponly);
  • 22. Session • Data stored on the server. • Advantages of session over cookies: • Secure • More data • Without cookies • Advantages of cookies over session: • Easier • Less of server • More time
  • 23. Setting the session • Session_start()
  • 24. • Accessing the session: $_SESSION • Deleting the session: • Unset($_SESSION[‘var’]); • $_SESSION=array(); • Session_destroy();
  • 25. Improving session security • Session ID and session data • HTTP_USER_AGENT $_SESSION[‘agent’]=md5($_SERVER[‘HTTP_USER_AGENT’]);