SlideShare ist ein Scribd-Unternehmen logo
1 von 56
Downloaden Sie, um offline zu lesen
Intro	
  to	
  Dynamic	
  Web	
  Pages	
  

               Jussi	
  Pohjolainen	
  
  Tampere	
  University	
  of	
  Applied	
  Sciences	
  
Contents	
  
•  IntroducAon	
  to	
  Programming	
  Concepts	
  
•  Web	
  ApplicaAon	
  Development	
  
   –  Architecture	
  
   –  StaAc	
  vs.	
  Dynamic	
  Web	
  Pages?	
  
   –  Client-­‐side	
  vs.	
  Server-­‐side	
  scripAng	
  
•  PHP	
  Programming	
  
   –  Embedding	
  PHP	
  into	
  Web	
  Pages	
  
   –  xhtml	
  forms	
  and	
  user	
  input	
  via	
  GET	
  
   –  Examples	
  of	
  Web	
  ApplicaAons	
  
INTRODUCTION	
  TO	
  PROGRAMMING	
  
Program?	
  
•  Computer	
  program,	
  applicaAon,	
  is	
  just	
  a	
  list	
  of	
  
   instrucAons	
  to	
  the	
  computer	
  
•  Program	
  gets	
  input	
  from	
  the	
  user	
  
•  Program	
  has	
  visible	
  output	
  
Machine	
  Language	
  
•  Program	
  is	
  just	
  an	
  instrucAons	
  to	
  the	
  CPU	
  
•  CPU	
  understands	
  only	
  machine	
  language	
  
•  Machine	
  language	
  is	
  very	
  hard	
  to	
  implement.	
  
Programming	
  Language	
  
•  Because	
  machine	
  language	
  is	
  so	
  hard	
  to	
  use	
  
   we	
  use	
  some	
  programming	
  language	
  
•  The	
  computer	
  understands	
  only	
  machine	
  
   language,	
  so	
  there	
  is	
  a	
  barrier	
  between	
  the	
  
   programming	
  language	
  and	
  machine	
  language	
  
•  Programming	
  language	
  can	
  be	
  compiled	
  to	
  
   machine	
  language	
  
Problem	
  
SoluAon	
  
Programming	
  Languages	
  
•  There	
  are	
  lot	
  of	
  different	
  programming	
  
   languages	
  
•  C++,	
  PHP,	
  Java,	
  C,	
  ...	
  
•  All	
  these	
  programming	
  languages	
  have	
  same	
  
   principals.	
  
Three	
  Basic	
  Rules	
  
•  1)	
  Sequence	
  
•  2)	
  Choice	
  
•  3)	
  Repeat	
  
Sequence	
  
•  Statements	
  are	
  executed	
  in	
  the	
  same	
  
   sequence	
  as	
  they	
  are	
  listed	
  in	
  the	
  source	
  code.	
  
    1.    print to the screen "what is your name"!
    2.    read user input to variable NAME!
    3.    print to the screen "You have a great name, "!
    4.    print NAME!
    5.    print "!"!
Choice	
  
•  With	
  choice	
  one	
  can	
  choose	
  what	
  sentences	
  
   are	
  executed	
  based	
  on	
  condiAon.	
  	
  

   1.    print to the screen "what is your name"!
   2.    read user input to variable NAME!
   3.    if(NAME = "Jussi")!
   4.        print to the screen "You have a silly name, "!
   5.    else!
   6.        print to the screen "You have a great name, "!
   7.    print NAME!
   8.    print "!"!
Repeat	
  
•  With	
  repeat	
  one	
  can	
  repeat	
  statements.	
  
   !
   1. print to the screen "what is your name"!
   2. read user input to variable NAME!
   3. while(NAME = "Jussi")!
   4.    print "This program is forbidden from Jussi"!
   5.    print "Give other name: "!
   6.    read user input to variable NAME!
   7. print to the screen "You have a great name, "!
   8. print NAME!
   9. print "!"!
What	
  is	
  the	
  output?	
  
i = 0!
while(i < 10)!
       print to the screen "Hello!"!
       i = i + 1!
Example	
  
print to the screen "Give your name"!
put the user input into variable NAME!
print to the screen "Give number"!
put the user input into variable NUMBER!
if(NUMBER < 1)!
   print to the screen "You have to give positive number"!
else!
   i = 0!
   while(i < NUMBER)!
        print NAME!
        i = i + 1!
!
!
Pseudocode	
  to	
  PHP	
  
•  Previous	
  examples	
  used	
  pseudocode	
  (not	
  real	
  
   programming	
  language)	
  
•  Examples	
  are	
  quite	
  close	
  to	
  real	
  programming	
  
   languages,	
  like	
  PHP	
  
Print	
  
•  PrinAng	
  to	
  the	
  screen	
  
•  Pseudocode	
  
    –  print to the screen "Give your name"	
  
•  PHP	
  
    –  print "Give your name";!
User	
  Input	
  
•  GeXng	
  user	
  input	
  
•  Pseudocode	
  
    –  put the user input into variable NAME!
•  PHP	
  
    –  $name = fgets(STDIN);	
  
Simple	
  Example	
  with	
  PHP	
  
<?php!
!
print "Give your name: ";!
$name = fgets(STDIN);!
print "You have a nice name: ";!
print $name;!
!
?>!
More	
  Complicated	
  Example:	
  PHP	
  
<?php!
!
print "Give your name: ";!
$name = fgets(STDIN);!
print "Give number: ";!
$number = fgets(STDIN);!
!
if($number < 1)!
{!
    print "You have to give positive number";!
}!
else!
{!
    $i = 0;!
    while($i < $number)!
    {!
         print $name;!
         $i = $i + 1;!
    }!
}!
!
?>!
!
Exercises	
  

hZp://Anyurl.com/my-­‐exercises	
  
WEB	
  APP	
  BASIC	
  CONCEPTS	
  
Intro	
  to	
  HTTP	
  
•  HTTP	
  (Hypertext	
  transfer	
  protocol)	
  is	
  a	
  
   stateless	
  protocol,	
  which	
  is	
  meant	
  to	
  
   transfer	
  informaAon	
  on	
  intranets	
  and	
  World	
  
   Wide	
  Web.	
  
   –  RFC2616:	
  
   –  hZp://www.w3.org/Protocols/rfc2616/rfc2616.html	
  
•  HTTP	
  is	
  a	
  request	
  /	
  response	
  standard	
  
   between	
  client	
  and	
  server	
  
Clients	
  and	
  Servers	
  
•  Client	
  
   –  Client	
  makes	
  a	
  hZp	
  request.	
  
   –  Client	
  can	
  be	
  a	
  web	
  browser,	
  spider	
  or	
  other	
  end-­‐user	
  
      tool	
  
   –  Client	
  is	
  referred	
  as	
  a	
  user	
  agent	
  
•  Server	
  
   –  Stores	
  informaAon	
  and	
  makes	
  them	
  available	
  to	
  the	
  
      client	
  
   –  Gives	
  hZp	
  response	
  to	
  the	
  client	
  
Request	
  and	
  Response	
  

Client	
                                        Client	
  
User-­‐agent:	
  Firefox	
                      Apache	
  HTTP	
  Server	
  

                                  request	
  

                                 response	
  
Response	
  when	
  Dealing	
  with	
  Scripts	
  
Three-­‐Aered	
  Web	
  Site:	
  LAMP	
  
Client	
                       example	
  request	
                  Server	
  
User-­‐agent:	
  Firefox	
     GET / HTTP/1.1!                       Apache	
  HTTP	
  Server	
  
                               Host: www.tamk.fi!
                               User-Agent: Mozilla/5.0 (Mac..)!
                               ...!
                               !


                                                response	
                       PHP	
  




                                                               Database	
  
                                                                 MySQL	
  
Server	
  Side	
  Techniques	
  
•  Server	
  side	
  scripAng	
  requires	
  installaAon	
  on	
  
   the	
  server	
  side	
  
•  Typically	
  client	
  sees	
  only	
  xhtml	
  and	
  it	
  is	
  
   unaware	
  that	
  the	
  xhtml	
  was	
  produced	
  by	
  a	
  
   server	
  side	
  script	
  
•  Does	
  not	
  require	
  any	
  installaAons	
  or	
  add-­‐ons	
  	
  
   on	
  the	
  client.	
  
Server	
  Side	
  Techniques	
  
•    PHP	
  
•    Java	
  EE:	
  Servlet,	
  JSP	
  
•    .NET	
  
•    CGI	
  /	
  Perl	
  (Very	
  old)	
  
•    Ruby	
  
•    …	
  
Client	
  Side	
  Techniques	
  
•  Requires	
  that	
  the	
  client	
  supports	
  the	
  
   technique	
  
•  JavaScript,	
  Applet,	
  Flash…	
  
PHP:	
  HYPERTEXT	
  PREPROCESSOR	
  
IntroducAon	
  to	
  PHP	
  
•  PHP	
  is	
  a	
  computer	
  scripAng	
  language.	
  
•  Originally	
  designed	
  for	
  producing	
  dynamic	
  web	
  
   pages	
  
•  Appeared	
  in	
  1995	
  
•  PHP	
  Group	
  is	
  responsible	
  for	
  the	
  language,	
  no	
  formal	
  
   specificaAon	
  
•  Free	
  soeware	
  
•  Runs	
  on	
  most	
  operaAng	
  systems	
  and	
  plaforms	
  
•  URL:	
  hZp://www.php.net	
  
PHP	
  in	
  Command	
  Line	
  
Running	
  the	
  same	
  Program	
  via	
  Web	
  
                   Browser	
  
The	
  Source	
  Code	
  of	
  the	
  Web	
  Page	
  
Problem?	
  
•  The	
  problem	
  here	
  is	
  that	
  the	
  output	
  is	
  not	
  
   valid	
  (x)html!	
  
•  The	
  output	
  of	
  the	
  PHP-­‐program	
  should	
  be	
  (x)
   html!	
  
One	
  possible	
  soluAon	
  
<?php!
print "<html>n";!
print "   <head><title>Example</title></head>n";!
print "   <body>n";!
!
$now = date("d.m.Y");!
print "   <p>" . $now . "</p>n";!
!
print "   </body>n";!
print "</html>n";!
?>!
!
!
Result	
  
Easier	
  way	
  
<html>!
   <head><title>Example</title></head>!
   <body>!
   <p>!
   <?php!
     $now = date("d.m.Y");!
     print $now;!
   ?> !
    </p> !
    </body>!
</html>!
!
Valid	
  XHTML	
  
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"!
      "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">!
<html xmlns="http://www.w3.org/1999/xhtml">!
<head>!
    <title>Example</title>!
    <meta http-equiv="content-type" content="application/xhtml+xml;
   charset=utf-8" />!
</head>    !
<body>!
   <p>!
   <?php!
     $now = date("d.m.Y");!
     print $now;!
   ?> !
    </p> !
    </body>!
</html>!
!
EXAMPLE:	
  SIMPLE	
  SLOT	
  MACHINE	
  
Exercises	
  
USER	
  INPUT	
  VIA	
  GET	
  
User	
  Input	
  in	
  CLI	
  
•  PHP	
  CLI	
  
    –  $name = fgets(STDIN);!
•  PHP	
  WEB	
  
    –  $name = $_GET['key'];!
Example	
  
<html>!
       <head><title>Example</title></head>!
       <body>!
     !
       <?php!
            $userInput = $_GET['key'];!
            print $userInput;!
       ?>!
        !
        </body>!
</html>!
	
  
	
  
Result?	
  
Giving	
  user	
  input	
  
Giving	
  user	
  input	
  
Example	
  
<html>!
       <head><title>Example</title></head>!
       <body>!
     !
       <?php!
            $name = $_GET['name'];!
            $age = $_GET['age'];!
            print "Your name is " . $name;!
            print " and your are " . $age;!
            print " years old.";!
       ?>!
        !
        </body>!
</html>!
	
  
	
  
Example	
  
Example	
  
USER	
  INPUT	
  VIA	
  FORMS	
  
Simple	
  StaAc	
  Web	
  Page	
  with	
  Form:	
  
                form.html!
<html>!
  <head>!
    <title>Get-example</title>!
  </head>!
  <body>!
 !<h1>Fill the form</h1>!
 !<form action="myprogram.php" method="GET">!
 !<p>Name!
 !<input type="text" name="name" /></p>!
  <p>Age!
 !<input type="text" name="age" /></p>!
 !<input type="submit" value="Send" />!
 !</form>!
 !!
</html>!
form.html	
  
Result:	
  myprogram.php	
  
EXERCISES	
  

Weitere ähnliche Inhalte

Was ist angesagt? (20)

Introduction to Kotlin coroutines
Introduction to Kotlin coroutinesIntroduction to Kotlin coroutines
Introduction to Kotlin coroutines
 
PHP - Introduction to PHP Fundamentals
PHP -  Introduction to PHP FundamentalsPHP -  Introduction to PHP Fundamentals
PHP - Introduction to PHP Fundamentals
 
Introduction to html 5
Introduction to html 5Introduction to html 5
Introduction to html 5
 
HTML Fundamentals
HTML FundamentalsHTML Fundamentals
HTML Fundamentals
 
Basics of JavaScript
Basics of JavaScriptBasics of JavaScript
Basics of JavaScript
 
RIA and Ajax
RIA and AjaxRIA and Ajax
RIA and Ajax
 
Introduction to Basic Concepts in Web
Introduction to Basic Concepts in WebIntroduction to Basic Concepts in Web
Introduction to Basic Concepts in Web
 
JavaScript - Chapter 11 - Events
 JavaScript - Chapter 11 - Events  JavaScript - Chapter 11 - Events
JavaScript - Chapter 11 - Events
 
PHP - Introduction to File Handling with PHP
PHP -  Introduction to  File Handling with PHPPHP -  Introduction to  File Handling with PHP
PHP - Introduction to File Handling with PHP
 
Javascript
JavascriptJavascript
Javascript
 
Php and MySQL
Php and MySQLPhp and MySQL
Php and MySQL
 
HTTP
HTTPHTTP
HTTP
 
Web technology lab manual
Web technology lab manualWeb technology lab manual
Web technology lab manual
 
React for Beginners
React for BeginnersReact for Beginners
React for Beginners
 
Basics PHP
Basics PHPBasics PHP
Basics PHP
 
Javascript
JavascriptJavascript
Javascript
 
Php
PhpPhp
Php
 
XML Document Object Model (DOM)
XML Document Object Model (DOM)XML Document Object Model (DOM)
XML Document Object Model (DOM)
 
HTML
HTMLHTML
HTML
 
Javascript variables and datatypes
Javascript variables and datatypesJavascript variables and datatypes
Javascript variables and datatypes
 

Andere mochten auch (20)

Static dynamic and active web pages
Static dynamic and active web pagesStatic dynamic and active web pages
Static dynamic and active web pages
 
Dynamic Web
Dynamic WebDynamic Web
Dynamic Web
 
presentation on static website design
presentation on static website designpresentation on static website design
presentation on static website design
 
Html Ppt
Html PptHtml Ppt
Html Ppt
 
Dynamic Web Programming
Dynamic Web ProgrammingDynamic Web Programming
Dynamic Web Programming
 
Scirus
ScirusScirus
Scirus
 
Web front end development introduction to html css and javascript
Web front end development introduction to html css and javascriptWeb front end development introduction to html css and javascript
Web front end development introduction to html css and javascript
 
Static web documents
Static web documents Static web documents
Static web documents
 
introduction of Java beans
introduction of Java beansintroduction of Java beans
introduction of Java beans
 
EJB3 Advance Features
EJB3 Advance FeaturesEJB3 Advance Features
EJB3 Advance Features
 
Jsp slides
Jsp slidesJsp slides
Jsp slides
 
Java EE EJB Applications
Java EE EJB ApplicationsJava EE EJB Applications
Java EE EJB Applications
 
Component object model and
Component object model andComponent object model and
Component object model and
 
Presentation On Com Dcom
Presentation On Com DcomPresentation On Com Dcom
Presentation On Com Dcom
 
Java beans
Java beansJava beans
Java beans
 
Dcom vs. corba
Dcom vs. corbaDcom vs. corba
Dcom vs. corba
 
Jsp
JspJsp
Jsp
 
Javabeans
JavabeansJavabeans
Javabeans
 
Gcm tutorial
Gcm tutorialGcm tutorial
Gcm tutorial
 
Java beans
Java beansJava beans
Java beans
 

Ähnlich wie Intro to Dynamic Web Pages

Ähnlich wie Intro to Dynamic Web Pages (20)

Php unit i
Php unit iPhp unit i
Php unit i
 
Prersentation
PrersentationPrersentation
Prersentation
 
Week 5
Week 5Week 5
Week 5
 
Week 5
Week 5Week 5
Week 5
 
PHP
PHPPHP
PHP
 
PHP ITCS 323
PHP ITCS 323PHP ITCS 323
PHP ITCS 323
 
Php mysql
Php mysqlPhp mysql
Php mysql
 
Presentation on php and Javascript
Presentation on php and JavascriptPresentation on php and Javascript
Presentation on php and Javascript
 
Php training100%placement-in-mumbai
Php training100%placement-in-mumbaiPhp training100%placement-in-mumbai
Php training100%placement-in-mumbai
 
php basics
php basicsphp basics
php basics
 
Php
PhpPhp
Php
 
Web Application Development using PHP Chapter 1
Web Application Development using PHP Chapter 1Web Application Development using PHP Chapter 1
Web Application Development using PHP Chapter 1
 
Lecture8
Lecture8Lecture8
Lecture8
 
php 1
php 1php 1
php 1
 
PHP Hypertext Preprocessor
PHP Hypertext PreprocessorPHP Hypertext Preprocessor
PHP Hypertext Preprocessor
 
Php i basic chapter 3 (mardhiah kamaludin's conflicted copy 2013-04-23)
Php i basic chapter 3 (mardhiah kamaludin's conflicted copy 2013-04-23)Php i basic chapter 3 (mardhiah kamaludin's conflicted copy 2013-04-23)
Php i basic chapter 3 (mardhiah kamaludin's conflicted copy 2013-04-23)
 
Php hypertext pre-processor
Php   hypertext pre-processorPhp   hypertext pre-processor
Php hypertext pre-processor
 
INTRODUCTION to php.pptx
INTRODUCTION to php.pptxINTRODUCTION to php.pptx
INTRODUCTION to php.pptx
 
PHP MySQL Workshop - facehook
PHP MySQL Workshop - facehookPHP MySQL Workshop - facehook
PHP MySQL Workshop - facehook
 
PHP NOTES FOR BEGGINERS
PHP NOTES FOR BEGGINERSPHP NOTES FOR BEGGINERS
PHP NOTES FOR BEGGINERS
 

Mehr von Jussi Pohjolainen

libGDX: Screens, Fonts and Preferences
libGDX: Screens, Fonts and PreferenceslibGDX: Screens, Fonts and Preferences
libGDX: Screens, Fonts and PreferencesJussi Pohjolainen
 
libGDX: User Input and Frame by Frame Animation
libGDX: User Input and Frame by Frame AnimationlibGDX: User Input and Frame by Frame Animation
libGDX: User Input and Frame by Frame AnimationJussi Pohjolainen
 
Intro to Building Android Games using libGDX
Intro to Building Android Games using libGDXIntro to Building Android Games using libGDX
Intro to Building Android Games using libGDXJussi Pohjolainen
 
Advanced JavaScript Development
Advanced JavaScript DevelopmentAdvanced JavaScript Development
Advanced JavaScript DevelopmentJussi Pohjolainen
 
libGDX: Simple Frame Animation
libGDX: Simple Frame AnimationlibGDX: Simple Frame Animation
libGDX: Simple Frame AnimationJussi Pohjolainen
 
libGDX: Simple Frame Animation
libGDX: Simple Frame AnimationlibGDX: Simple Frame Animation
libGDX: Simple Frame AnimationJussi Pohjolainen
 
Implementing a Simple Game using libGDX
Implementing a Simple Game using libGDXImplementing a Simple Game using libGDX
Implementing a Simple Game using libGDXJussi Pohjolainen
 
Building Android games using LibGDX
Building Android games using LibGDXBuilding Android games using LibGDX
Building Android games using LibGDXJussi Pohjolainen
 
Creating Asha Games: Game Pausing, Orientation, Sensors and Gestures
Creating Asha Games: Game Pausing, Orientation, Sensors and GesturesCreating Asha Games: Game Pausing, Orientation, Sensors and Gestures
Creating Asha Games: Game Pausing, Orientation, Sensors and GesturesJussi Pohjolainen
 
Creating Games for Asha - platform
Creating Games for Asha - platformCreating Games for Asha - platform
Creating Games for Asha - platformJussi Pohjolainen
 

Mehr von Jussi Pohjolainen (20)

Moved to Speakerdeck
Moved to SpeakerdeckMoved to Speakerdeck
Moved to Speakerdeck
 
Java Web Services
Java Web ServicesJava Web Services
Java Web Services
 
Box2D and libGDX
Box2D and libGDXBox2D and libGDX
Box2D and libGDX
 
libGDX: Screens, Fonts and Preferences
libGDX: Screens, Fonts and PreferenceslibGDX: Screens, Fonts and Preferences
libGDX: Screens, Fonts and Preferences
 
libGDX: Tiled Maps
libGDX: Tiled MapslibGDX: Tiled Maps
libGDX: Tiled Maps
 
libGDX: User Input and Frame by Frame Animation
libGDX: User Input and Frame by Frame AnimationlibGDX: User Input and Frame by Frame Animation
libGDX: User Input and Frame by Frame Animation
 
Intro to Building Android Games using libGDX
Intro to Building Android Games using libGDXIntro to Building Android Games using libGDX
Intro to Building Android Games using libGDX
 
Advanced JavaScript Development
Advanced JavaScript DevelopmentAdvanced JavaScript Development
Advanced JavaScript Development
 
Introduction to JavaScript
Introduction to JavaScriptIntroduction to JavaScript
Introduction to JavaScript
 
Introduction to AngularJS
Introduction to AngularJSIntroduction to AngularJS
Introduction to AngularJS
 
libGDX: Scene2D
libGDX: Scene2DlibGDX: Scene2D
libGDX: Scene2D
 
libGDX: Simple Frame Animation
libGDX: Simple Frame AnimationlibGDX: Simple Frame Animation
libGDX: Simple Frame Animation
 
libGDX: Simple Frame Animation
libGDX: Simple Frame AnimationlibGDX: Simple Frame Animation
libGDX: Simple Frame Animation
 
libGDX: User Input
libGDX: User InputlibGDX: User Input
libGDX: User Input
 
Implementing a Simple Game using libGDX
Implementing a Simple Game using libGDXImplementing a Simple Game using libGDX
Implementing a Simple Game using libGDX
 
Building Android games using LibGDX
Building Android games using LibGDXBuilding Android games using LibGDX
Building Android games using LibGDX
 
Android Threading
Android ThreadingAndroid Threading
Android Threading
 
Creating Asha Games: Game Pausing, Orientation, Sensors and Gestures
Creating Asha Games: Game Pausing, Orientation, Sensors and GesturesCreating Asha Games: Game Pausing, Orientation, Sensors and Gestures
Creating Asha Games: Game Pausing, Orientation, Sensors and Gestures
 
Creating Games for Asha - platform
Creating Games for Asha - platformCreating Games for Asha - platform
Creating Games for Asha - platform
 
Intro to Asha UI
Intro to Asha UIIntro to Asha UI
Intro to Asha UI
 

Kürzlich hochgeladen

The Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxThe Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxMalak Abu Hammad
 
CNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of ServiceCNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of Servicegiselly40
 
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking MenDelhi Call girls
 
Developing An App To Navigate The Roads of Brazil
Developing An App To Navigate The Roads of BrazilDeveloping An App To Navigate The Roads of Brazil
Developing An App To Navigate The Roads of BrazilV3cube
 
[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdfhans926745
 
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...Neo4j
 
Breaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountBreaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountPuma Security, LLC
 
Salesforce Community Group Quito, Salesforce 101
Salesforce Community Group Quito, Salesforce 101Salesforce Community Group Quito, Salesforce 101
Salesforce Community Group Quito, Salesforce 101Paola De la Torre
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Miguel Araújo
 
Handwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsHandwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsMaria Levchenko
 
Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024The Digital Insurer
 
Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...
Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...
Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...gurkirankumar98700
 
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...Igalia
 
🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘RTylerCroy
 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonAnna Loughnan Colquhoun
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024Rafal Los
 
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking MenDelhi Call girls
 
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptxHampshireHUG
 
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc
 
Factors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptxFactors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptxKatpro Technologies
 

Kürzlich hochgeladen (20)

The Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxThe Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptx
 
CNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of ServiceCNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of Service
 
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
 
Developing An App To Navigate The Roads of Brazil
Developing An App To Navigate The Roads of BrazilDeveloping An App To Navigate The Roads of Brazil
Developing An App To Navigate The Roads of Brazil
 
[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf
 
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
 
Breaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountBreaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path Mount
 
Salesforce Community Group Quito, Salesforce 101
Salesforce Community Group Quito, Salesforce 101Salesforce Community Group Quito, Salesforce 101
Salesforce Community Group Quito, Salesforce 101
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
 
Handwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsHandwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed texts
 
Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024
 
Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...
Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...
Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...
 
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
 
🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘
 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt Robison
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024
 
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
 
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
 
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
 
Factors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptxFactors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptx
 

Intro to Dynamic Web Pages

  • 1. Intro  to  Dynamic  Web  Pages   Jussi  Pohjolainen   Tampere  University  of  Applied  Sciences  
  • 2. Contents   •  IntroducAon  to  Programming  Concepts   •  Web  ApplicaAon  Development   –  Architecture   –  StaAc  vs.  Dynamic  Web  Pages?   –  Client-­‐side  vs.  Server-­‐side  scripAng   •  PHP  Programming   –  Embedding  PHP  into  Web  Pages   –  xhtml  forms  and  user  input  via  GET   –  Examples  of  Web  ApplicaAons  
  • 4. Program?   •  Computer  program,  applicaAon,  is  just  a  list  of   instrucAons  to  the  computer   •  Program  gets  input  from  the  user   •  Program  has  visible  output  
  • 5. Machine  Language   •  Program  is  just  an  instrucAons  to  the  CPU   •  CPU  understands  only  machine  language   •  Machine  language  is  very  hard  to  implement.  
  • 6. Programming  Language   •  Because  machine  language  is  so  hard  to  use   we  use  some  programming  language   •  The  computer  understands  only  machine   language,  so  there  is  a  barrier  between  the   programming  language  and  machine  language   •  Programming  language  can  be  compiled  to   machine  language  
  • 9. Programming  Languages   •  There  are  lot  of  different  programming   languages   •  C++,  PHP,  Java,  C,  ...   •  All  these  programming  languages  have  same   principals.  
  • 10. Three  Basic  Rules   •  1)  Sequence   •  2)  Choice   •  3)  Repeat  
  • 11. Sequence   •  Statements  are  executed  in  the  same   sequence  as  they  are  listed  in  the  source  code.   1.  print to the screen "what is your name"! 2.  read user input to variable NAME! 3.  print to the screen "You have a great name, "! 4.  print NAME! 5.  print "!"!
  • 12. Choice   •  With  choice  one  can  choose  what  sentences   are  executed  based  on  condiAon.     1.  print to the screen "what is your name"! 2.  read user input to variable NAME! 3.  if(NAME = "Jussi")! 4.  print to the screen "You have a silly name, "! 5.  else! 6.  print to the screen "You have a great name, "! 7.  print NAME! 8.  print "!"!
  • 13. Repeat   •  With  repeat  one  can  repeat  statements.   ! 1. print to the screen "what is your name"! 2. read user input to variable NAME! 3. while(NAME = "Jussi")! 4.  print "This program is forbidden from Jussi"! 5.  print "Give other name: "! 6.  read user input to variable NAME! 7. print to the screen "You have a great name, "! 8. print NAME! 9. print "!"!
  • 14. What  is  the  output?   i = 0! while(i < 10)! print to the screen "Hello!"! i = i + 1!
  • 15. Example   print to the screen "Give your name"! put the user input into variable NAME! print to the screen "Give number"! put the user input into variable NUMBER! if(NUMBER < 1)! print to the screen "You have to give positive number"! else! i = 0! while(i < NUMBER)! print NAME! i = i + 1! ! !
  • 16. Pseudocode  to  PHP   •  Previous  examples  used  pseudocode  (not  real   programming  language)   •  Examples  are  quite  close  to  real  programming   languages,  like  PHP  
  • 17. Print   •  PrinAng  to  the  screen   •  Pseudocode   –  print to the screen "Give your name"   •  PHP   –  print "Give your name";!
  • 18. User  Input   •  GeXng  user  input   •  Pseudocode   –  put the user input into variable NAME! •  PHP   –  $name = fgets(STDIN);  
  • 19. Simple  Example  with  PHP   <?php! ! print "Give your name: ";! $name = fgets(STDIN);! print "You have a nice name: ";! print $name;! ! ?>!
  • 20. More  Complicated  Example:  PHP   <?php! ! print "Give your name: ";! $name = fgets(STDIN);! print "Give number: ";! $number = fgets(STDIN);! ! if($number < 1)! {! print "You have to give positive number";! }! else! {! $i = 0;! while($i < $number)! {! print $name;! $i = $i + 1;! }! }! ! ?>! !
  • 22. WEB  APP  BASIC  CONCEPTS  
  • 23. Intro  to  HTTP   •  HTTP  (Hypertext  transfer  protocol)  is  a   stateless  protocol,  which  is  meant  to   transfer  informaAon  on  intranets  and  World   Wide  Web.   –  RFC2616:   –  hZp://www.w3.org/Protocols/rfc2616/rfc2616.html   •  HTTP  is  a  request  /  response  standard   between  client  and  server  
  • 24. Clients  and  Servers   •  Client   –  Client  makes  a  hZp  request.   –  Client  can  be  a  web  browser,  spider  or  other  end-­‐user   tool   –  Client  is  referred  as  a  user  agent   •  Server   –  Stores  informaAon  and  makes  them  available  to  the   client   –  Gives  hZp  response  to  the  client  
  • 25. Request  and  Response   Client   Client   User-­‐agent:  Firefox   Apache  HTTP  Server   request   response  
  • 26. Response  when  Dealing  with  Scripts  
  • 27. Three-­‐Aered  Web  Site:  LAMP   Client   example  request   Server   User-­‐agent:  Firefox   GET / HTTP/1.1! Apache  HTTP  Server   Host: www.tamk.fi! User-Agent: Mozilla/5.0 (Mac..)! ...! ! response   PHP   Database   MySQL  
  • 28. Server  Side  Techniques   •  Server  side  scripAng  requires  installaAon  on   the  server  side   •  Typically  client  sees  only  xhtml  and  it  is   unaware  that  the  xhtml  was  produced  by  a   server  side  script   •  Does  not  require  any  installaAons  or  add-­‐ons     on  the  client.  
  • 29. Server  Side  Techniques   •  PHP   •  Java  EE:  Servlet,  JSP   •  .NET   •  CGI  /  Perl  (Very  old)   •  Ruby   •  …  
  • 30. Client  Side  Techniques   •  Requires  that  the  client  supports  the   technique   •  JavaScript,  Applet,  Flash…  
  • 32. IntroducAon  to  PHP   •  PHP  is  a  computer  scripAng  language.   •  Originally  designed  for  producing  dynamic  web   pages   •  Appeared  in  1995   •  PHP  Group  is  responsible  for  the  language,  no  formal   specificaAon   •  Free  soeware   •  Runs  on  most  operaAng  systems  and  plaforms   •  URL:  hZp://www.php.net  
  • 33. PHP  in  Command  Line  
  • 34. Running  the  same  Program  via  Web   Browser  
  • 35. The  Source  Code  of  the  Web  Page  
  • 36. Problem?   •  The  problem  here  is  that  the  output  is  not   valid  (x)html!   •  The  output  of  the  PHP-­‐program  should  be  (x) html!  
  • 37. One  possible  soluAon   <?php! print "<html>n";! print " <head><title>Example</title></head>n";! print " <body>n";! ! $now = date("d.m.Y");! print " <p>" . $now . "</p>n";! ! print " </body>n";! print "</html>n";! ?>! ! !
  • 39. Easier  way   <html>! <head><title>Example</title></head>! <body>! <p>! <?php! $now = date("d.m.Y");! print $now;! ?> ! </p> ! </body>! </html>! !
  • 40. Valid  XHTML   <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"! "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">! <html xmlns="http://www.w3.org/1999/xhtml">! <head>! <title>Example</title>! <meta http-equiv="content-type" content="application/xhtml+xml; charset=utf-8" />! </head> ! <body>! <p>! <?php! $now = date("d.m.Y");! print $now;! ?> ! </p> ! </body>! </html>! !
  • 41. EXAMPLE:  SIMPLE  SLOT  MACHINE  
  • 43. USER  INPUT  VIA  GET  
  • 44. User  Input  in  CLI   •  PHP  CLI   –  $name = fgets(STDIN);! •  PHP  WEB   –  $name = $_GET['key'];!
  • 45. Example   <html>! <head><title>Example</title></head>! <body>! ! <?php! $userInput = $_GET['key'];! print $userInput;! ?>! ! </body>! </html>!    
  • 49. Example   <html>! <head><title>Example</title></head>! <body>! ! <?php! $name = $_GET['name'];! $age = $_GET['age'];! print "Your name is " . $name;! print " and your are " . $age;! print " years old.";! ?>! ! </body>! </html>!    
  • 52. USER  INPUT  VIA  FORMS  
  • 53. Simple  StaAc  Web  Page  with  Form:   form.html! <html>! <head>! <title>Get-example</title>! </head>! <body>! !<h1>Fill the form</h1>! !<form action="myprogram.php" method="GET">! !<p>Name! !<input type="text" name="name" /></p>! <p>Age! !<input type="text" name="age" /></p>! !<input type="submit" value="Send" />! !</form>! !! </html>!