SlideShare a Scribd company logo
Dynamic Web Programming: Application and Transfer
Active Server Pages (ASP)When a browser calls an ASP document, the ASP Server reads the .asp document andSubstitutes appropriate files for the (server-side) include statementsRuns the ASP code (Visual Basic Script – see the Tutorial and Language Reference, …)Returns the resulting HTML code to the browserExample (code, copy of database)
ASP Key Points (1)ASP code enclosed in: <% VBScript code %>Everything outside is HTMLThe result of the combined HTML and ASP code must be a “standard” HTML document, e.g.:<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Final//EN"><html><head><title>Miracle Drug Study</title><meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"><meta name="Description" content=""><meta name="Keywords" content=""><link rel=STYLESHEET type="text/css" href=""></head><body></body></html>
ASP Key Points (2)Connect with database:Create connection object:set conn = Server.CreateObject("ADODB.Connection")Open connection:conn.open("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=f:\web\database\rescomp\study.mdb")Submit a (read-only) Query:Generate SQL statement:SQL = "SELECT FirstName, LastName, DOB, Gender FROM Patients WHERE Gender = '" & Gender & "' ORDER BY FirstName DESC"set Patients = conn.execute(SQL)
ASP Key Points (3)Move through the data records:do while NOT Patients.eof	Name = Patients(0) & " " & Patients(1)	Patients.MoveNextloopAdd to or edit table:Create and open Record Set object:set RS = Server.CreateObject("ADODB.Recordset")RS.Open “table name", conn, , adLockOptimistic, adCmdTable(where adLockOptimistic = 3, adCmdTable = 2)
ASP Key Points (4)Add to or edit table (continued):Create new record, Edit, & Update:RS.AddNewRS(“Dosage”) = 200RS.UpdateOr Find desired record, Edit, & Update :do while NOT RS.eof	if RS(“ID”) = 7 then		RS(“Dosage”) = 200		RS.Update	else		RS.MoveNext	end ifloop
ASP Key Points (5)Clean up (free server resources) when done:Queries:Patients.Closeset Patients = nothingRecord Sets:RS.Closeset RS = nothingThe Connection:conn.closeset conn = nothing
ASP SecurityApart from various Internet Information Services (IIS – Window’s Web service) security holes (for viruses and worms), security is quite good.Use https:// if you want to protect content over the internet – provides Secure Socket Layer (SSL) security
ASP ResourcesASP IntroductionMicrosoft’s VBScript Tutorial & Language Reference (also here)WebMonkey’s tutorial
ColdFusionEasy-to-learn Server-Side Scripting Language: CFML, or Cold Fusion Markup Language, is embedded in HTML codeCF code is enclosed in or by CF tags: <CFtagnameCF code ><Cftagname > CF Code </Cftagname >Documents must end in .cfmColdFusion is Case InsensitiveExample (code, copy of database)
ColdFusion Key Points (1)All #variables# are enclosed in # signsHTML output which includes of CF variables must be surrounded by CF output tags; e.g.:<Cfset height = “tall”><CFoutput>The <B>#height#</B> boy fell.<Cfoutput>
ColdFusion Key Points (1)Connect with database and run query simultaneously:<CFQUERY Name="Patients" dbtype="dynamic" connectstring="#DBdriver# #DBfile#">SELECT ID, FirstName, LastName FROM PatientsORDER BY FirstName</CFQUERY>	Where the variables are defined beforehand:<CFset Dbdriver = "Driver={MICROSOFT ACCESS DRIVER (*.mdb)}; UID=admin; PWD=; dbq="><CFset Dbfile = "f:\web\database\rescomp\study.mdb">
ColdFusion Key Points (2)Access Query Results<SELECT name="PatientID"><CFoutput QUERY="Patients">		<OPTION value=#ID#>#FirstName# #LastName#</CFoutput></SELECT>Insert Data from a FormIf a HTML form submits variables to be inserted, do so directly using CFinsert:<CFinsert tablename="Treatment" dbtype="dynamic" connectstring="#DBdriver# #DBfile#">	All variables in the form object (e.g. Form.var1) that match attributes in the table are inserted into the table automatically
ColdFusion Key Points (3)Insert Data using Cfquery (SQL):<CFquery name="Treatment" dbtype="dynamic" connectstring="#DBdriver# #DBfile#">INSERT into TreatmentVALUES (#PatientID#, #EventID#, Now(), #Dosage(mg)#, #Severity#, #Time#)</CFquery>Other Data editing features also available; see documentation
Cold Fusion ResourcesCold Fusion IntroductionAllaire/Macromedia’s Documentation Web page Developing CF ApplicationsCFML ReferenceCFML Quick ReferenceWebMonkey’s tutorialSecurity links page
Practical Extraction andReport Language (Perl)UbiquitousOriginally designed to be a better general purpose tool than a Unix shell, it has grown and spread to be supported from Windows to Macintosh to VMS.Powerful but CrypticExample (code)
Perl Key Points (1)The file itself must end in “.cgi” or “.pl”First linemust specify the location of the Perl engine (The DBI module will not work for “#!/usr/local/bin /perl[5]” – see below):#!/uva/bin/perl -wFirst printed line must be the following if you want its response to go to a browser:print "Content-type: text/html\n\n";
Perl Key Points (3)Set the usual parameters:my $hostname = “lebec.tc.edu"; my $username = “gordie";  # "my" defines a local variablemy $password = “mine122";my $database = $username . "_study";  # = dld5s_studymy $data_source = "DBI:mysql:$database:$hostname";Connect to the database:my $dbh = DBI->connect($data_source, $username, $password)or die "Can't connect to $data_source: $DBI::errstr\n";
Perl Key Points (4)Define the SQL statement and executemy $SQL = "SELECT FirstName, LastName, DOB, Gender        FROM Patients        WHERE Gender = '$Gender‘        ORDER BY FirstName DESC";my $sth = $dbh->prepare($SQL)or die "Unable to prepare $SQL: dbh->errstr\n";$sth->execute or die "Unable to execute query: $dbh->errstr\n";Clean up$sth->finish;$dbh->disconnect;
Perl ResourcesPerl Programming IntroductionPerl Programming for the WebPerl DocumentationOverview, Built-in functions, Data types, Regular expressions, …Modules: DBI(1), DBI(2), CGIWebMonkey’s Tutorial, etc.MySQL and PERL for the Web by DuBois (New Riders)Learning Perl by Schwartz & Christiansen (O’Reilly)Programming Perl by Wall, Orwant, & Christiansen (O’Reilly)Programming the Perl DBI: Database Programming with Perl by Descartes, Bunce, & Mui (Editor) (O’Reilly)
PHPExampleAdd SourceIndex Source
PHP: Hypertext Preprocessor (PHP)HTML embedding scripting language (see the PHP online manualWhen a browser calls a PHP document, the Server reads the PHP document andRuns the PHP codeReturns the resulting HTML code to the browserExample (code)
PHP Key Points (1)Filename must end in .php or .phtmlPHP code enclosed in <?php PHP code ?> or <? PHP code ?>Everything outside is HTMLOutput is (generally) to a browser requiring standard HTML
PHP Key Points (2)Connecting with RDBMS and editing, adding, and deleting databases therein are all done through PHP functionsConnect with MySQL RDBMSmysql_connect($hostName, $userName, $password) or die("Unable to connect to host $hostName");Connect with databasemysql_select_db($dbName) or die("Unable to select database $dbName");
PHP Key Points (3)Queries: Nearly all table interaction and management is done through queries:Basic information searches$SQL = "SELECT FirstName, LastName, DOB, Gender FROM Patients WHERE Gender = '$Gender‘ ORDER BY FirstName DESC";$Patients = mysql_query($SQL);Editing, adding, and deleting records and tables$SQL = "INSERT INTO Patients (FirstName, LastName) VALUES('$firstName', '$lastName')";$Patients = mysql_query($SQL);
PHP Key Points (4)Cleaning up: close the database connectionmysql_close();
PHP/MySQL SecurityThe same problems as PHP occur with Perl if you run it as a Perl or CGI script.  See the passwords link
PHP ResourcesPHP and MySQLPHP DocumentationPHP’s TutorialWebMonkey’s TutorialPHP and MySQL Web Development by Welling & Thomson (SAMS)Beginning PHP4 by Blan, Choi, et. al (Wrox)
(Other) BooksMySQL by DuBois (New Riders)MySQL and PERL for the Web by DuBois (New Riders)MySQL & mSQL byYarger, Reese, & KingPHP and MySQL Web Development by Welling & Thomson (SAMS)Beginning PHP4 by Blan, Choi, et. al (Wrox)Learning Perl by Schwartz & Christiansen (O’Reilly)Programming Perl by Wall, Orwant, & Christiansen (O’Reilly)Programming the Perl DBI: Database Programming with Perl by Descartes, Bunce, & Mui (Editor) (O’Reilly)SQL-99 Complete, Really by Gulutzan & Pelzer (R&D Books)
PHPPHP is a widely-used general-purpose scripting language that is especially suited for Web development and can be embedded into HTML.PHP is a project of the Apache Software Foundation. PHP stands for PHP: Hypertext Preprocessor.
Let’s get started.As we already said PHP can be embedded into HTML:#!/usr/local/bin/php<html><body><?php	echo “Hello I am a PHP script”;?></body></html>
First fileSave the file with a PHP extension in your public_html folder.Give the webserver execute permission (chmod 755 hello.php is the easiest way to do this)Point a webserver at the fileLet’s look at the first line of the file#!/usr/local/bin/php
Something more Useful<?php	echo $_SERVER["REMOTE_ADDR”]; ?>What is echo(); ?	echo() is a PHP function which prints output to the webpage, php has many functions that do this, print(), printf() are two examples.What is $_SERVER?!$_SERVER is a special reserved PHP variable that contains all web server information. It's known as an Autoglobal (or Superglobal).
Mixin and matchin PHP & HTML<?php if (strstr($_SERVER["HTTP_USER_AGENT"], "MSIE")) {?><h3>strstr must have returned true</h3><center><b>You are using InternetExplorer</b></center> <?php } else { ?> <h3>strstr must have returned false</h3> <center><b>You are not using Internet Explorer</b></center> <?php } ?>Here we see you can mix and match HTML and PHP together, this is because PHP does the PHP bit first, it’s output is HTML and then bangs all the HTML together.
PHP FormsForms are a useful part of any internet site, and I’m sure you’ve used them in the past.  Forms are part of HTML, however you can pass their values to a PHP script. Here is a simple HTML form which you can put in any HTML file:<form action="action.php" method="POST"> Your name: <input type="text" name="name">Your age: <input type="text" name="age"> <input type="submit"> </form>This isn’t specific to PHP, the only thing to notice is how we pass the values to “action.php”
Handling POST dataNow we edit action.php (of course this file can be called whatever, as long as the form passes it on).Hi <?php echo $_POST["name"]; ?>.You are <?php echo $_POST["age"]; ?> years old.
Handling POST data$_POST[] is an autoglobal array which get’s created at every webpage by the server.Sample out put from our script would be:Hi Joe. You are 22 years old
Data TypesThere are eight data types in PHP (which isn’t a lot), I’m going to cover three, the others are not used a lot and would be considered advanced in the contexts of PHP anyways.  Data types in PHP, unlike, are flexible or not strict, and are refrenced the same way, so inter-chaging is simple.
Data Types$bool = TRUE; // a boolean $str = "foo"; // a string $int = 12; // an integer echogettype($bool); // prints out"boolean" echo gettype($str); // prints out "string" // If this is an integer, increment it by fourif (is_int($int)) { $int += 4; } /* If $bool is a string, print it out (does not print out anything) */if (is_string($bool)) { echo "String: $bool"; }
Manulipating Data TypesThese types can be added, subtracted, concatinated like they can be in C or Java$a = 5;$b = 4;Echo ($a + $b); // prints 9!$string = “touch”;$end = “down”;Echo $string.$end;  //prints touchdown!
Control StructuresIf:$hey = TRUE;If($hey) {	printf(“Hello\n”);} else {	printf(“Never gona see this!\n”);}
While$a = 0;While($a < 100) {	printf(“hello $a\n”);	a++;}Prints all the numbers from 0 to 99.
For & othersFor($a = 0; $a < 100; $a++){	printf(“Hello $a\n”);}//prints all the numbers from 0 to 99 againPHP has also all the other control structures you can think of, until, do, switch, : ?
Global VariablesWe’ve already seen the use of some global or Super variables in $_POST and $_SERVER.  There’s a good few of them which can be useful to make your site more personal.  To get a list of them, create this PHP file.#!/usr/local/bin/php<?php phpinfo(); ?>
ResourcesThis helpdesk tutorial like the others is just geared to get you started at PHP coding.  PHP’s website is the best resource for consultation, www.php.net it has a simple to follow tutorial (you might find striking resemblances with tonite’s!), as well as a manual page for every function in PHP.  I recommend you go to the site for more detailed descriptions of what we did tonite.
Why is PHP good?Php is good for a number of reasonsEasy to useWell documentedLarge libraryGood Database interactionGood for Projects!!See Paul Acquaro’s class this Summer.
Ad

Recommended

Intro to Dynamic Web Pages
Intro to Dynamic Web Pages
Jussi Pohjolainen
 
Tech talk php_cms
Tech talk php_cms
Shehrevar Davierwala
 
Php Presentation
Php Presentation
Manish Bothra
 
Tech talk webtech
Tech talk webtech
Shehrevar Davierwala
 
Web Application Development using PHP Chapter 1
Web Application Development using PHP Chapter 1
Mohd Harris Ahmad Jaal
 
PHP - Introduction to PHP Fundamentals
PHP - Introduction to PHP Fundamentals
Vibrant Technologies & Computers
 
PHP, PHP Developer, Hire PHP Developer, PHP Web Development, Hire PHP Program...
PHP, PHP Developer, Hire PHP Developer, PHP Web Development, Hire PHP Program...
bchrisopher
 
Php unit i
Php unit i
BagavathiLakshmi
 
Php hypertext pre-processor
Php hypertext pre-processor
Siddique Ibrahim
 
Overview of PHP and MYSQL
Overview of PHP and MYSQL
Deblina Chowdhury
 
Phpbasics
Phpbasics
PrinceGuru MS
 
Introduction to php
Introduction to php
Meetendra Singh
 
Php intro
Php intro
Jennie Gajjar
 
Php intro
Php intro
sana mateen
 
Presentation php
Presentation php
Muhammad Saqib Malik
 
Php unit i
Php unit i
prakashvs7
 
Enterprise PHP (php|works 2008)
Enterprise PHP (php|works 2008)
Ivo Jansch
 
PHP ITCS 323
PHP ITCS 323
Sleepy Head
 
01 Php Introduction
01 Php Introduction
Geshan Manandhar
 
Advanced PHP Web Development Tools in 2015
Advanced PHP Web Development Tools in 2015
iScripts
 
Linux Apache Php Mysql Lamp1273
Linux Apache Php Mysql Lamp1273
hussulinux
 
PHP LICTURES ..........
PHP LICTURES ..........
Rashid Ahmad
 
PHP and Web Services
PHP and Web Services
Bruno Pedro
 
Top 100 PHP Questions and Answers
Top 100 PHP Questions and Answers
iimjobs and hirist
 
Coldfusion
Coldfusion
Ram
 
PHP and Platform Independance in the Cloud
PHP and Platform Independance in the Cloud
ZendCon
 
Introduction to php
Introduction to php
Taha Malampatti
 
Database driven web pages
Database driven web pages
Information Technology
 
php
php
J.T.A.JONES
 
Open Source Package Php Mysql 1228203701094763 9
Open Source Package Php Mysql 1228203701094763 9
isadorta
 

More Related Content

What's hot (19)

Php hypertext pre-processor
Php hypertext pre-processor
Siddique Ibrahim
 
Overview of PHP and MYSQL
Overview of PHP and MYSQL
Deblina Chowdhury
 
Phpbasics
Phpbasics
PrinceGuru MS
 
Introduction to php
Introduction to php
Meetendra Singh
 
Php intro
Php intro
Jennie Gajjar
 
Php intro
Php intro
sana mateen
 
Presentation php
Presentation php
Muhammad Saqib Malik
 
Php unit i
Php unit i
prakashvs7
 
Enterprise PHP (php|works 2008)
Enterprise PHP (php|works 2008)
Ivo Jansch
 
PHP ITCS 323
PHP ITCS 323
Sleepy Head
 
01 Php Introduction
01 Php Introduction
Geshan Manandhar
 
Advanced PHP Web Development Tools in 2015
Advanced PHP Web Development Tools in 2015
iScripts
 
Linux Apache Php Mysql Lamp1273
Linux Apache Php Mysql Lamp1273
hussulinux
 
PHP LICTURES ..........
PHP LICTURES ..........
Rashid Ahmad
 
PHP and Web Services
PHP and Web Services
Bruno Pedro
 
Top 100 PHP Questions and Answers
Top 100 PHP Questions and Answers
iimjobs and hirist
 
Coldfusion
Coldfusion
Ram
 
PHP and Platform Independance in the Cloud
PHP and Platform Independance in the Cloud
ZendCon
 
Introduction to php
Introduction to php
Taha Malampatti
 
Php hypertext pre-processor
Php hypertext pre-processor
Siddique Ibrahim
 
Enterprise PHP (php|works 2008)
Enterprise PHP (php|works 2008)
Ivo Jansch
 
Advanced PHP Web Development Tools in 2015
Advanced PHP Web Development Tools in 2015
iScripts
 
Linux Apache Php Mysql Lamp1273
Linux Apache Php Mysql Lamp1273
hussulinux
 
PHP LICTURES ..........
PHP LICTURES ..........
Rashid Ahmad
 
PHP and Web Services
PHP and Web Services
Bruno Pedro
 
Top 100 PHP Questions and Answers
Top 100 PHP Questions and Answers
iimjobs and hirist
 
Coldfusion
Coldfusion
Ram
 
PHP and Platform Independance in the Cloud
PHP and Platform Independance in the Cloud
ZendCon
 

Similar to Dynamic Web Programming (20)

Database driven web pages
Database driven web pages
Information Technology
 
php
php
J.T.A.JONES
 
Open Source Package Php Mysql 1228203701094763 9
Open Source Package Php Mysql 1228203701094763 9
isadorta
 
Open Source Package PHP & MySQL
Open Source Package PHP & MySQL
kalaisai
 
PHP and MySQL PHP Written as a set of CGI binaries in C in ...
PHP and MySQL PHP Written as a set of CGI binaries in C in ...
webhostingguy
 
Php summary
Php summary
Michelle Darling
 
Lect_04b_PhpMysqlKEY PERFORMANCE INDICATOR FOR ICT-UNIT (new).ppt
Lect_04b_PhpMysqlKEY PERFORMANCE INDICATOR FOR ICT-UNIT (new).ppt
SenzotaSemakuwa
 
PHP MySQL
PHP MySQL
Md. Sirajus Salayhin
 
Php with mysql ppt
Php with mysql ppt
Rajamanickam Gomathijayam
 
Download It
Download It
webhostingguy
 
Php and MySQL Web Development
Php and MySQL Web Development
w3ondemand
 
P H P Part I I, By Kian
P H P Part I I, By Kian
phelios
 
Web programming
Web programming
Ishucs
 
working with PHP & DB's
working with PHP & DB's
Hi-Tech College
 
IT Club @ NCP - PHP Workshop May 10, 2011
IT Club @ NCP - PHP Workshop May 10, 2011
IT Club GTA
 
Php
Php
khushbulakhani1
 
PHP and MySQL
PHP and MySQL
bmani
 
PHP Workshop Notes
PHP Workshop Notes
Pamela Fox
 
Php
Php
samirlakhanistb
 
Article 01 What Is Php
Article 01 What Is Php
drperl
 
Open Source Package Php Mysql 1228203701094763 9
Open Source Package Php Mysql 1228203701094763 9
isadorta
 
Open Source Package PHP & MySQL
Open Source Package PHP & MySQL
kalaisai
 
PHP and MySQL PHP Written as a set of CGI binaries in C in ...
PHP and MySQL PHP Written as a set of CGI binaries in C in ...
webhostingguy
 
Lect_04b_PhpMysqlKEY PERFORMANCE INDICATOR FOR ICT-UNIT (new).ppt
Lect_04b_PhpMysqlKEY PERFORMANCE INDICATOR FOR ICT-UNIT (new).ppt
SenzotaSemakuwa
 
Php and MySQL Web Development
Php and MySQL Web Development
w3ondemand
 
P H P Part I I, By Kian
P H P Part I I, By Kian
phelios
 
Web programming
Web programming
Ishucs
 
IT Club @ NCP - PHP Workshop May 10, 2011
IT Club @ NCP - PHP Workshop May 10, 2011
IT Club GTA
 
PHP and MySQL
PHP and MySQL
bmani
 
PHP Workshop Notes
PHP Workshop Notes
Pamela Fox
 
Article 01 What Is Php
Article 01 What Is Php
drperl
 
Ad

More from Information Technology (20)

Web303
Web303
Information Technology
 
Sql Server Security Best Practices
Sql Server Security Best Practices
Information Technology
 
SAN
SAN
Information Technology
 
SAN Review
SAN Review
Information Technology
 
SQL 2005 Disk IO Performance
SQL 2005 Disk IO Performance
Information Technology
 
RAID Review
RAID Review
Information Technology
 
Review of SQL
Review of SQL
Information Technology
 
Sql 2005 high availability
Sql 2005 high availability
Information Technology
 
IIS 7: The Administrator’s Guide
IIS 7: The Administrator’s Guide
Information Technology
 
MOSS 2007 Deployment Fundamentals -Part2
MOSS 2007 Deployment Fundamentals -Part2
Information Technology
 
MOSS 2007 Deployment Fundamentals -Part1
MOSS 2007 Deployment Fundamentals -Part1
Information Technology
 
Clustering and High Availability
Clustering and High Availability
Information Technology
 
F5 beyond load balancer (nov 2009)
F5 beyond load balancer (nov 2009)
Information Technology
 
WSS 3.0 & SharePoint 2007
WSS 3.0 & SharePoint 2007
Information Technology
 
SharePoint Topology
SharePoint Topology
Information Technology
 
Sharepoint Deployments
Sharepoint Deployments
Information Technology
 
Microsoft Clustering
Microsoft Clustering
Information Technology
 
Scalable Internet Servers and Load Balancing
Scalable Internet Servers and Load Balancing
Information Technology
 
Web Hacking
Web Hacking
Information Technology
 
Migration from ASP to ASP.NET
Migration from ASP to ASP.NET
Information Technology
 
Ad

Recently uploaded (20)

Improving Data Integrity: Synchronization between EAM and ArcGIS Utility Netw...
Improving Data Integrity: Synchronization between EAM and ArcGIS Utility Netw...
Safe Software
 
Crypto Super 500 - 14th Report - June2025.pdf
Crypto Super 500 - 14th Report - June2025.pdf
Stephen Perrenod
 
Turning the Page – How AI is Exponentially Increasing Speed, Accuracy, and Ef...
Turning the Page – How AI is Exponentially Increasing Speed, Accuracy, and Ef...
Impelsys Inc.
 
FIDO Seminar: Targeting Trust: The Future of Identity in the Workforce.pptx
FIDO Seminar: Targeting Trust: The Future of Identity in the Workforce.pptx
FIDO Alliance
 
Raman Bhaumik - Passionate Tech Enthusiast
Raman Bhaumik - Passionate Tech Enthusiast
Raman Bhaumik
 
"How to survive Black Friday: preparing e-commerce for a peak season", Yurii ...
"How to survive Black Friday: preparing e-commerce for a peak season", Yurii ...
Fwdays
 
Connecting Data and Intelligence: The Role of FME in Machine Learning
Connecting Data and Intelligence: The Role of FME in Machine Learning
Safe Software
 
“From Enterprise to Makers: Driving Vision AI Innovation at the Extreme Edge,...
“From Enterprise to Makers: Driving Vision AI Innovation at the Extreme Edge,...
Edge AI and Vision Alliance
 
Information Security Response Team Nepal_npCERT_Vice_President_Sudan_Jha.pdf
Information Security Response Team Nepal_npCERT_Vice_President_Sudan_Jha.pdf
ICT Frame Magazine Pvt. Ltd.
 
FIDO Seminar: Perspectives on Passkeys & Consumer Adoption.pptx
FIDO Seminar: Perspectives on Passkeys & Consumer Adoption.pptx
FIDO Alliance
 
Enhance GitHub Copilot using MCP - Enterprise version.pdf
Enhance GitHub Copilot using MCP - Enterprise version.pdf
Nilesh Gule
 
No-Code Workflows for CAD & 3D Data: Scaling AI-Driven Infrastructure
No-Code Workflows for CAD & 3D Data: Scaling AI-Driven Infrastructure
Safe Software
 
"Database isolation: how we deal with hundreds of direct connections to the d...
"Database isolation: how we deal with hundreds of direct connections to the d...
Fwdays
 
Creating Inclusive Digital Learning with AI: A Smarter, Fairer Future
Creating Inclusive Digital Learning with AI: A Smarter, Fairer Future
Impelsys Inc.
 
War_And_Cyber_3_Years_Of_Struggle_And_Lessons_For_Global_Security.pdf
War_And_Cyber_3_Years_Of_Struggle_And_Lessons_For_Global_Security.pdf
biswajitbanerjee38
 
Python Conference Singapore - 19 Jun 2025
Python Conference Singapore - 19 Jun 2025
ninefyi
 
FME for Distribution & Transmission Integrity Management Program (DIMP & TIMP)
FME for Distribution & Transmission Integrity Management Program (DIMP & TIMP)
Safe Software
 
The Future of Technology: 2025-2125 by Saikat Basu.pdf
The Future of Technology: 2025-2125 by Saikat Basu.pdf
Saikat Basu
 
FIDO Seminar: New Data: Passkey Adoption in the Workforce.pptx
FIDO Seminar: New Data: Passkey Adoption in the Workforce.pptx
FIDO Alliance
 
The Future of Data, AI, and AR: Innovation Inspired by You.pdf
The Future of Data, AI, and AR: Innovation Inspired by You.pdf
Safe Software
 
Improving Data Integrity: Synchronization between EAM and ArcGIS Utility Netw...
Improving Data Integrity: Synchronization between EAM and ArcGIS Utility Netw...
Safe Software
 
Crypto Super 500 - 14th Report - June2025.pdf
Crypto Super 500 - 14th Report - June2025.pdf
Stephen Perrenod
 
Turning the Page – How AI is Exponentially Increasing Speed, Accuracy, and Ef...
Turning the Page – How AI is Exponentially Increasing Speed, Accuracy, and Ef...
Impelsys Inc.
 
FIDO Seminar: Targeting Trust: The Future of Identity in the Workforce.pptx
FIDO Seminar: Targeting Trust: The Future of Identity in the Workforce.pptx
FIDO Alliance
 
Raman Bhaumik - Passionate Tech Enthusiast
Raman Bhaumik - Passionate Tech Enthusiast
Raman Bhaumik
 
"How to survive Black Friday: preparing e-commerce for a peak season", Yurii ...
"How to survive Black Friday: preparing e-commerce for a peak season", Yurii ...
Fwdays
 
Connecting Data and Intelligence: The Role of FME in Machine Learning
Connecting Data and Intelligence: The Role of FME in Machine Learning
Safe Software
 
“From Enterprise to Makers: Driving Vision AI Innovation at the Extreme Edge,...
“From Enterprise to Makers: Driving Vision AI Innovation at the Extreme Edge,...
Edge AI and Vision Alliance
 
Information Security Response Team Nepal_npCERT_Vice_President_Sudan_Jha.pdf
Information Security Response Team Nepal_npCERT_Vice_President_Sudan_Jha.pdf
ICT Frame Magazine Pvt. Ltd.
 
FIDO Seminar: Perspectives on Passkeys & Consumer Adoption.pptx
FIDO Seminar: Perspectives on Passkeys & Consumer Adoption.pptx
FIDO Alliance
 
Enhance GitHub Copilot using MCP - Enterprise version.pdf
Enhance GitHub Copilot using MCP - Enterprise version.pdf
Nilesh Gule
 
No-Code Workflows for CAD & 3D Data: Scaling AI-Driven Infrastructure
No-Code Workflows for CAD & 3D Data: Scaling AI-Driven Infrastructure
Safe Software
 
"Database isolation: how we deal with hundreds of direct connections to the d...
"Database isolation: how we deal with hundreds of direct connections to the d...
Fwdays
 
Creating Inclusive Digital Learning with AI: A Smarter, Fairer Future
Creating Inclusive Digital Learning with AI: A Smarter, Fairer Future
Impelsys Inc.
 
War_And_Cyber_3_Years_Of_Struggle_And_Lessons_For_Global_Security.pdf
War_And_Cyber_3_Years_Of_Struggle_And_Lessons_For_Global_Security.pdf
biswajitbanerjee38
 
Python Conference Singapore - 19 Jun 2025
Python Conference Singapore - 19 Jun 2025
ninefyi
 
FME for Distribution & Transmission Integrity Management Program (DIMP & TIMP)
FME for Distribution & Transmission Integrity Management Program (DIMP & TIMP)
Safe Software
 
The Future of Technology: 2025-2125 by Saikat Basu.pdf
The Future of Technology: 2025-2125 by Saikat Basu.pdf
Saikat Basu
 
FIDO Seminar: New Data: Passkey Adoption in the Workforce.pptx
FIDO Seminar: New Data: Passkey Adoption in the Workforce.pptx
FIDO Alliance
 
The Future of Data, AI, and AR: Innovation Inspired by You.pdf
The Future of Data, AI, and AR: Innovation Inspired by You.pdf
Safe Software
 

Dynamic Web Programming

  • 1. Dynamic Web Programming: Application and Transfer
  • 2. Active Server Pages (ASP)When a browser calls an ASP document, the ASP Server reads the .asp document andSubstitutes appropriate files for the (server-side) include statementsRuns the ASP code (Visual Basic Script – see the Tutorial and Language Reference, …)Returns the resulting HTML code to the browserExample (code, copy of database)
  • 3. ASP Key Points (1)ASP code enclosed in: <% VBScript code %>Everything outside is HTMLThe result of the combined HTML and ASP code must be a “standard” HTML document, e.g.:<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Final//EN"><html><head><title>Miracle Drug Study</title><meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"><meta name="Description" content=""><meta name="Keywords" content=""><link rel=STYLESHEET type="text/css" href=""></head><body></body></html>
  • 4. ASP Key Points (2)Connect with database:Create connection object:set conn = Server.CreateObject("ADODB.Connection")Open connection:conn.open("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=f:\web\database\rescomp\study.mdb")Submit a (read-only) Query:Generate SQL statement:SQL = "SELECT FirstName, LastName, DOB, Gender FROM Patients WHERE Gender = '" & Gender & "' ORDER BY FirstName DESC"set Patients = conn.execute(SQL)
  • 5. ASP Key Points (3)Move through the data records:do while NOT Patients.eof Name = Patients(0) & " " & Patients(1) Patients.MoveNextloopAdd to or edit table:Create and open Record Set object:set RS = Server.CreateObject("ADODB.Recordset")RS.Open “table name", conn, , adLockOptimistic, adCmdTable(where adLockOptimistic = 3, adCmdTable = 2)
  • 6. ASP Key Points (4)Add to or edit table (continued):Create new record, Edit, & Update:RS.AddNewRS(“Dosage”) = 200RS.UpdateOr Find desired record, Edit, & Update :do while NOT RS.eof if RS(“ID”) = 7 then RS(“Dosage”) = 200 RS.Update else RS.MoveNext end ifloop
  • 7. ASP Key Points (5)Clean up (free server resources) when done:Queries:Patients.Closeset Patients = nothingRecord Sets:RS.Closeset RS = nothingThe Connection:conn.closeset conn = nothing
  • 8. ASP SecurityApart from various Internet Information Services (IIS – Window’s Web service) security holes (for viruses and worms), security is quite good.Use https:// if you want to protect content over the internet – provides Secure Socket Layer (SSL) security
  • 9. ASP ResourcesASP IntroductionMicrosoft’s VBScript Tutorial & Language Reference (also here)WebMonkey’s tutorial
  • 10. ColdFusionEasy-to-learn Server-Side Scripting Language: CFML, or Cold Fusion Markup Language, is embedded in HTML codeCF code is enclosed in or by CF tags: <CFtagnameCF code ><Cftagname > CF Code </Cftagname >Documents must end in .cfmColdFusion is Case InsensitiveExample (code, copy of database)
  • 11. ColdFusion Key Points (1)All #variables# are enclosed in # signsHTML output which includes of CF variables must be surrounded by CF output tags; e.g.:<Cfset height = “tall”><CFoutput>The <B>#height#</B> boy fell.<Cfoutput>
  • 12. ColdFusion Key Points (1)Connect with database and run query simultaneously:<CFQUERY Name="Patients" dbtype="dynamic" connectstring="#DBdriver# #DBfile#">SELECT ID, FirstName, LastName FROM PatientsORDER BY FirstName</CFQUERY> Where the variables are defined beforehand:<CFset Dbdriver = "Driver={MICROSOFT ACCESS DRIVER (*.mdb)}; UID=admin; PWD=; dbq="><CFset Dbfile = "f:\web\database\rescomp\study.mdb">
  • 13. ColdFusion Key Points (2)Access Query Results<SELECT name="PatientID"><CFoutput QUERY="Patients"> <OPTION value=#ID#>#FirstName# #LastName#</CFoutput></SELECT>Insert Data from a FormIf a HTML form submits variables to be inserted, do so directly using CFinsert:<CFinsert tablename="Treatment" dbtype="dynamic" connectstring="#DBdriver# #DBfile#"> All variables in the form object (e.g. Form.var1) that match attributes in the table are inserted into the table automatically
  • 14. ColdFusion Key Points (3)Insert Data using Cfquery (SQL):<CFquery name="Treatment" dbtype="dynamic" connectstring="#DBdriver# #DBfile#">INSERT into TreatmentVALUES (#PatientID#, #EventID#, Now(), #Dosage(mg)#, #Severity#, #Time#)</CFquery>Other Data editing features also available; see documentation
  • 15. Cold Fusion ResourcesCold Fusion IntroductionAllaire/Macromedia’s Documentation Web page Developing CF ApplicationsCFML ReferenceCFML Quick ReferenceWebMonkey’s tutorialSecurity links page
  • 16. Practical Extraction andReport Language (Perl)UbiquitousOriginally designed to be a better general purpose tool than a Unix shell, it has grown and spread to be supported from Windows to Macintosh to VMS.Powerful but CrypticExample (code)
  • 17. Perl Key Points (1)The file itself must end in “.cgi” or “.pl”First linemust specify the location of the Perl engine (The DBI module will not work for “#!/usr/local/bin /perl[5]” – see below):#!/uva/bin/perl -wFirst printed line must be the following if you want its response to go to a browser:print "Content-type: text/html\n\n";
  • 18. Perl Key Points (3)Set the usual parameters:my $hostname = “lebec.tc.edu"; my $username = “gordie"; # "my" defines a local variablemy $password = “mine122";my $database = $username . "_study"; # = dld5s_studymy $data_source = "DBI:mysql:$database:$hostname";Connect to the database:my $dbh = DBI->connect($data_source, $username, $password)or die "Can't connect to $data_source: $DBI::errstr\n";
  • 19. Perl Key Points (4)Define the SQL statement and executemy $SQL = "SELECT FirstName, LastName, DOB, Gender FROM Patients WHERE Gender = '$Gender‘ ORDER BY FirstName DESC";my $sth = $dbh->prepare($SQL)or die "Unable to prepare $SQL: dbh->errstr\n";$sth->execute or die "Unable to execute query: $dbh->errstr\n";Clean up$sth->finish;$dbh->disconnect;
  • 20. Perl ResourcesPerl Programming IntroductionPerl Programming for the WebPerl DocumentationOverview, Built-in functions, Data types, Regular expressions, …Modules: DBI(1), DBI(2), CGIWebMonkey’s Tutorial, etc.MySQL and PERL for the Web by DuBois (New Riders)Learning Perl by Schwartz & Christiansen (O’Reilly)Programming Perl by Wall, Orwant, & Christiansen (O’Reilly)Programming the Perl DBI: Database Programming with Perl by Descartes, Bunce, & Mui (Editor) (O’Reilly)
  • 22. PHP: Hypertext Preprocessor (PHP)HTML embedding scripting language (see the PHP online manualWhen a browser calls a PHP document, the Server reads the PHP document andRuns the PHP codeReturns the resulting HTML code to the browserExample (code)
  • 23. PHP Key Points (1)Filename must end in .php or .phtmlPHP code enclosed in <?php PHP code ?> or <? PHP code ?>Everything outside is HTMLOutput is (generally) to a browser requiring standard HTML
  • 24. PHP Key Points (2)Connecting with RDBMS and editing, adding, and deleting databases therein are all done through PHP functionsConnect with MySQL RDBMSmysql_connect($hostName, $userName, $password) or die("Unable to connect to host $hostName");Connect with databasemysql_select_db($dbName) or die("Unable to select database $dbName");
  • 25. PHP Key Points (3)Queries: Nearly all table interaction and management is done through queries:Basic information searches$SQL = "SELECT FirstName, LastName, DOB, Gender FROM Patients WHERE Gender = '$Gender‘ ORDER BY FirstName DESC";$Patients = mysql_query($SQL);Editing, adding, and deleting records and tables$SQL = "INSERT INTO Patients (FirstName, LastName) VALUES('$firstName', '$lastName')";$Patients = mysql_query($SQL);
  • 26. PHP Key Points (4)Cleaning up: close the database connectionmysql_close();
  • 27. PHP/MySQL SecurityThe same problems as PHP occur with Perl if you run it as a Perl or CGI script. See the passwords link
  • 28. PHP ResourcesPHP and MySQLPHP DocumentationPHP’s TutorialWebMonkey’s TutorialPHP and MySQL Web Development by Welling & Thomson (SAMS)Beginning PHP4 by Blan, Choi, et. al (Wrox)
  • 29. (Other) BooksMySQL by DuBois (New Riders)MySQL and PERL for the Web by DuBois (New Riders)MySQL & mSQL byYarger, Reese, & KingPHP and MySQL Web Development by Welling & Thomson (SAMS)Beginning PHP4 by Blan, Choi, et. al (Wrox)Learning Perl by Schwartz & Christiansen (O’Reilly)Programming Perl by Wall, Orwant, & Christiansen (O’Reilly)Programming the Perl DBI: Database Programming with Perl by Descartes, Bunce, & Mui (Editor) (O’Reilly)SQL-99 Complete, Really by Gulutzan & Pelzer (R&D Books)
  • 30. PHPPHP is a widely-used general-purpose scripting language that is especially suited for Web development and can be embedded into HTML.PHP is a project of the Apache Software Foundation. PHP stands for PHP: Hypertext Preprocessor.
  • 31. Let’s get started.As we already said PHP can be embedded into HTML:#!/usr/local/bin/php<html><body><?php echo “Hello I am a PHP script”;?></body></html>
  • 32. First fileSave the file with a PHP extension in your public_html folder.Give the webserver execute permission (chmod 755 hello.php is the easiest way to do this)Point a webserver at the fileLet’s look at the first line of the file#!/usr/local/bin/php
  • 33. Something more Useful<?php echo $_SERVER["REMOTE_ADDR”]; ?>What is echo(); ? echo() is a PHP function which prints output to the webpage, php has many functions that do this, print(), printf() are two examples.What is $_SERVER?!$_SERVER is a special reserved PHP variable that contains all web server information. It's known as an Autoglobal (or Superglobal).
  • 34. Mixin and matchin PHP & HTML<?php if (strstr($_SERVER["HTTP_USER_AGENT"], "MSIE")) {?><h3>strstr must have returned true</h3><center><b>You are using InternetExplorer</b></center> <?php } else { ?> <h3>strstr must have returned false</h3> <center><b>You are not using Internet Explorer</b></center> <?php } ?>Here we see you can mix and match HTML and PHP together, this is because PHP does the PHP bit first, it’s output is HTML and then bangs all the HTML together.
  • 35. PHP FormsForms are a useful part of any internet site, and I’m sure you’ve used them in the past. Forms are part of HTML, however you can pass their values to a PHP script. Here is a simple HTML form which you can put in any HTML file:<form action="action.php" method="POST"> Your name: <input type="text" name="name">Your age: <input type="text" name="age"> <input type="submit"> </form>This isn’t specific to PHP, the only thing to notice is how we pass the values to “action.php”
  • 36. Handling POST dataNow we edit action.php (of course this file can be called whatever, as long as the form passes it on).Hi <?php echo $_POST["name"]; ?>.You are <?php echo $_POST["age"]; ?> years old.
  • 37. Handling POST data$_POST[] is an autoglobal array which get’s created at every webpage by the server.Sample out put from our script would be:Hi Joe. You are 22 years old
  • 38. Data TypesThere are eight data types in PHP (which isn’t a lot), I’m going to cover three, the others are not used a lot and would be considered advanced in the contexts of PHP anyways. Data types in PHP, unlike, are flexible or not strict, and are refrenced the same way, so inter-chaging is simple.
  • 39. Data Types$bool = TRUE; // a boolean $str = "foo"; // a string $int = 12; // an integer echogettype($bool); // prints out"boolean" echo gettype($str); // prints out "string" // If this is an integer, increment it by fourif (is_int($int)) { $int += 4; } /* If $bool is a string, print it out (does not print out anything) */if (is_string($bool)) { echo "String: $bool"; }
  • 40. Manulipating Data TypesThese types can be added, subtracted, concatinated like they can be in C or Java$a = 5;$b = 4;Echo ($a + $b); // prints 9!$string = “touch”;$end = “down”;Echo $string.$end; //prints touchdown!
  • 41. Control StructuresIf:$hey = TRUE;If($hey) { printf(“Hello\n”);} else { printf(“Never gona see this!\n”);}
  • 42. While$a = 0;While($a < 100) { printf(“hello $a\n”); a++;}Prints all the numbers from 0 to 99.
  • 43. For & othersFor($a = 0; $a < 100; $a++){ printf(“Hello $a\n”);}//prints all the numbers from 0 to 99 againPHP has also all the other control structures you can think of, until, do, switch, : ?
  • 44. Global VariablesWe’ve already seen the use of some global or Super variables in $_POST and $_SERVER. There’s a good few of them which can be useful to make your site more personal. To get a list of them, create this PHP file.#!/usr/local/bin/php<?php phpinfo(); ?>
  • 45. ResourcesThis helpdesk tutorial like the others is just geared to get you started at PHP coding. PHP’s website is the best resource for consultation, www.php.net it has a simple to follow tutorial (you might find striking resemblances with tonite’s!), as well as a manual page for every function in PHP. I recommend you go to the site for more detailed descriptions of what we did tonite.
  • 46. Why is PHP good?Php is good for a number of reasonsEasy to useWell documentedLarge libraryGood Database interactionGood for Projects!!See Paul Acquaro’s class this Summer.