M.P. Johnson, DBMS, Stern/NYU, Spring 20051 C20.0046: Database Management Systems Lecture #21 M.P. Johnson Stern School of Business, NYU Spring, 2005.

Slides:



Advertisements
Similar presentations
JQuery MessageBoard. Lets use jQuery and AJAX in combination with a database to update and retrieve information without refreshing the page. Here we will.
Advertisements

WEB DESIGN TABLES, PAGE LAYOUT AND FORMS. Page Layout Page Layout is an important part of web design Why do you think your page layout is important?
PHP Hypertext Preprocessor Information Systems 337 Prof. Harry Plantinga.
Murali Mani SQL-PL Interface. Murali Mani Some Possible Options Web Interface Perl /CGI with Oracle/mySQL Install your own web server and use servlets.
W EB A PPLICATION D EVELOPMENT A PPLICATION T O B IO -I NFORMATICS -III Vicky Khanna M-Tech Bioinformatics.
1 Topic 6 Processing Form Input. 2Outline Goals and Objectives Goals and Objectives Chapter Headlines Chapter Headlines Introduction Introduction Form.
DT228/3 Web Development WWW and Client server model.
M.P. Johnson, DBMS, Stern/NYU, Sp20041 C : Database Management Systems Lecture #20 Matthew P. Johnson Stern School of Business, NYU Spring, 2004.
Languages for Dynamic Web Documents
Copyright 2004 Monash University IMS5401 Web-based Systems Development Topic 2: Elements of the Web (g) Interactivity.
M.P. Johnson, DBMS, Stern/NYU, Spring C : Database Management Systems Lecture #20 M.P. Johnson Stern School of Business, NYU Spring, 2005.
M.P. Johnson, DBMS, Stern/NYU, Sp20041 C : Database Management Systems Lecture #17 Matthew P. Johnson Stern School of Business, NYU Spring, 2004.
M.P. Johnson, DBMS, Stern/NYU, Sp20041 C : Database Management Systems Lecture #18 Matthew P. Johnson Stern School of Business, NYU Spring, 2004.
Master’s course Bioinformatics Data Analysis and Tools Lecture 6: Internet Basics Centre for Integrative Bioinformatics.
M.P. Johnson, DBMS, Stern/NYU, Spring C : Database Management Systems Lecture #22 M.P. Johnson Stern School of Business, NYU Spring, 2005.
Outline IS400: Development of Business Applications on the Internet Fall 2004 Instructor: Dr. Boris Jukic Server Side Web Technologies: Part 2.
M.P. Johnson, DBMS, Stern/NYU, Sp20041 C : Database Management Systems Lecture #21 Matthew P. Johnson Stern School of Business, NYU Spring, 2004.
Multiple Tiers in Action
M.P. Johnson, DBMS, Stern/NYU, Spring C : Database Management Systems Lecture #17 M.P. Johnson Stern School of Business, NYU Spring, 2008.
Python and Web Programming
M.P. Johnson, DBMS, Stern/NYU, Spring C : Database Management Systems Lecture #16 M.P. Johnson Stern School of Business, NYU Spring, 2008.
CGI Programming: Part 1. What is CGI? CGI = Common Gateway Interface Provides a standardized way for web browsers to: –Call programs on a server. –Pass.
2440: 141 Web Site Administration Web Server-Side Programming Professor: Enoch E. Damson.
1 CS428 Web Engineering Lecture 18 Introduction (PHP - I)
PHP and SQL Server: Queries IST2101. Project Report 4 SQL Queries Due Sunday, 4/5 at 11:59pm Instructions on how to access team webspace and SQL database.
+ Connecting to the Web Week 7, Lecture A. + Midterm Basics Thursday February 28 during Class The lab Tuesday, February 26 is optional review Class on.
DAT602 Database Application Development Lecture 15 Java Server Pages Part 1.
1 Web Developer & Design Foundations with XHTML Chapter 6 Key Concepts.
CGI Common Gateway Interface. CGI is the scheme to interface other programs to the Web Server.
1 Web Database Processing. Web Database Applications Static Report Publishing a report is prepared from a database application and exported to HTML DB.
1 Homework / Exam Exam 3 –Solutions Posted –Questions? HW8 due next class Final Exam –See posted schedule Websites on UNIX systems Course Evaluations.
1 CS 3870/CS 5870 Static and Dynamic Web Pages ASP.NET and IIS.
1 HTML and CGI Scripting CSC8304 – Computing Environments for Bioinformatics - Lecture 10.
1 CS 3870/CS 5870 Static and Dynamic Web Pages ASP.NET and IIS.
Comp2513 Forms and CGI Server Applications Daniel L. Silver, Ph.D.
Server-side Scripting Powering the webs favourite services.
Basics of Web Databases With the advent of Web database technology, Web pages are no longer static, but dynamic with connection to a back-end database.
Lecture 7 Interaction. Topics Implementing data flows An internet solution Transactions in MySQL 4-tier systems – business rule/presentation separation.
1 PHP and MySQL. 2 Topics  Querying Data with PHP  User-Driven Querying  Writing Data with PHP and MySQL PHP and MySQL.
PHP meets MySQL.
Web Server Administration Chapter 7 Installing and Testing a Programming Environment.
Lecture # 6 Forms, Widgets and Event Handling. Today Questions: From notes/reading/life? Share Personal Web Page (if not too personal) 1.Introduce: How.
20-753: Fundamentals of Web Programming Copyright © 1999, Carnegie Mellon. All Rights Reserved. 1 Lecture 7: HTTP and CGI Fundamentals of Web Programming.
JavaScript – Quiz #9 Lecture Code:
Creating Dynamic Web Pages Using PHP and MySQL CS 320.
Putting it all together Dynamic Data Base Access Norman White Stern School of Business.
Website Development with PHP and MySQL Saving Data.
Basic & Advanced Reporting in TIMSNT ** Part Two **
1 © Netskills Quality Internet Training, University of Newcastle HTML Forms © Netskills, Quality Internet Training, University of Newcastle Netskills is.
ITCS373: Internet Technology Lecture 5: More HTML.
CSC 2720 Building Web Applications Server-side Scripting with PHP.
CHAPTER 7 Form & PHP. Introduction All of the following examples in this section will require two web pages. The first page retrieves information posted.
Creating PHPs to Insert, Update, and Delete Data CS 320.
Intro to PHP IST2101. Review: HTML & Tags 2IST210.
CS 4720 Dynamic Web Applications CS 4720 – Web & Mobile Systems.
Java server pages. A JSP file basically contains HTML, but with embedded JSP tags with snippets of Java code inside them. A JSP file basically contains.
David Lawrence 7/8/091Intro. to PHP -- David Lawrence.
Copyright 2007 Byrne Reese. Distributed under Creative Commons, share and share alike with attribution. Intermediate Perl Programming Class Three Instructor:
1) PHP – Personal Home Page Scripting Language 2) JavaScript.
1 PHP Intro PHP Introduction After this lecture, you should be able to: Know the fundamental concepts of Web Scripting Languages in general, PHP in particular.
COSC 2328 – Web Programming.  PHP is a server scripting language  It’s widely-used and free  It’s an alternative to Microsoft’s ASP and Ruby  PHP.
World Wide Web has been created to share the text document across the world. In static web pages the requesting user has no ability to interact with the.
IST 210: PHP Basics IST 210: Organization of Data IST2101.
PHP and SQL Server: Connection IST 210: Organization of Data IST2101.
Section 6.3 Server-side Scripting
Server-Side Application and Data Management IT IS 3105 (Spring 2010)
PHP / MySQL Introduction
Perl Database – Just Enough
Lecture 5: Functions and Parameters
Presentation transcript:

M.P. Johnson, DBMS, Stern/NYU, Spring C : Database Management Systems Lecture #21 M.P. Johnson Stern School of Business, NYU Spring, 2005

M.P. Johnson, DBMS, Stern/NYU, Spring Homework Project part 4 due today  Topic: populating your tables with data  Using MySQL’s bulk loader  Start early!  Turn in on time Project part 5  Topic: web interface + any remaining loose ends  Posted soon…  Due: end of semester

M.P. Johnson, DBMS, Stern/NYU, Spring Agenda: Programming for SQL Have now been exposed to:  Embedded SQL: Pro*C  Java JDBC  Stored Procedures: PL/SQL All used; good to know about Most important for this course:  DB-conn from web scripting languages  DBI/DBDs in Perl, PHP

M.P. Johnson, DBMS, Stern/NYU, Spring Goals: after this week After Tuesday: be able to post a hello-web Perl script in your sales account After Today: 1. be able to post a hello-web PHP script in your sales account 2. Be able to modify/extend non-trivial Perl/PHP scripts to work with your DB Take input from user Execute SQL query Display formatted results

M.P. Johnson, DBMS, Stern/NYU, Spring Review: CGI/Perl Program Client Server HTTP Request Data for program Generated HTML HTML Image from

M.P. Johnson, DBMS, Stern/NYU, Spring New topic: HTML forms Interactive parts of HTML: forms Intuition for name: paper form  Fill in textboxes, check boxes or not, etc.  Turn it in (press button) HTML form  contains arb. # of INPUTs  Submits to somewhere (ACTION)  By GET or POST

M.P. Johnson, DBMS, Stern/NYU, Spring Form example On clicking Send, we go to the same page, but with “name=99&sumbit=OK” Enter a number: Enter a number:

M.P. Johnson, DBMS, Stern/NYU, Spring Perl and forms Obtain param number: Goal: display text and button;  On submit, tell user what was entered Improve: also print, say, triple the input… my $cgi = CGI->new(); $param = $cgi->param('number'); my $cgi = CGI->new(); $param = $cgi->param('number');

M.P. Johnson, DBMS, Stern/NYU, Spring Perl error-handling Many Perl scripts have lines of the form  some-statement OR die(“something happened”); What this means:  die exits with error message  Perl supports both || and OR as or operator  Perl supports boolean “short-circuiting” Boolean eval stops as fast as possible  Ftns often return 0/null/false for errors  if some-statement fails then we die

M.P. Johnson, DBMS, Stern/NYU, Spring Perl and databases DB connectivity is done through DBI  Database Interface  Analogous to Java’s JDBC  The steps correspond roughly 1-1 Think of DBI as a Java class with static methods Use these to obtain a connection, prepare and execute queries, etc.

M.P. Johnson, DBMS, Stern/NYU, Spring Perl DBI 1. Open a connection: 2. Prepare and execute query: my $dbh = DBI-> connect("dbi:mysql:database=mydb; mysql2.stern.nyu.edu;port=3306", user, pass); my $sth = $dbh->prepare($query); $sth->execute; my $sth = $dbh->prepare($query); $sth->execute;

M.P. Johnson, DBMS, Stern/NYU, Spring Perl DBI 3. Extract next row of data from statement results, if available:  What this means: row has two fields, whose values are put in $a and $b, in order  Other options, but this should suffice In general, want to scroll through results:  Braces { } are required! my ($a, $b) = $sth->fetchrow_array() while (my ($a, $b) = $sth->fetchrow_array()) { # print out $a and $b } while (my ($a, $b) = $sth->fetchrow_array()) { # print out $a and $b }

M.P. Johnson, DBMS, Stern/NYU, Spring Limit: Perl webpages that do something Semi-interesting Perl script:   Non-trivial but not huge: ~40 lines Works with two-column (a,b) table  Takes input from user  Returns rows whose a field contains value  If no/empty input, returns all rows Bad idea in general!

M.P. Johnson, DBMS, Stern/NYU, Spring lookup.cgi Two possible situations for running script: 1. Page opened for the first time 2. User entered parameter and pressed button Structure of file: 1. Print input box and button for next search  On button click, parameter is sent to this page’s url 2. (Try to) read input parameter 3. Open MySQL connection 4. Run query 5. Print results in a table 6. Disconnect from MySQL

M.P. Johnson, DBMS, Stern/NYU, Spring Higher-level structure As one page:  If we have params, display data based on them  Otherwise, prompt user for params, call self Could be:  Page 1: prompt for params, call page 2  Page 2: display data based on params In e.g.: always display data for convenience

M.P. Johnson, DBMS, Stern/NYU, Spring Tutorials on Perl Some material drawn from the following good tutorials: CGI backend programming using perl:  Perl Basics:  CGI Basics:  MySQL/Perl/CGI example: 

M.P. Johnson, DBMS, Stern/NYU, Spring That’s all, folks! Q: Is this enough to get a job coding Perl? A: Probably not! But: Don’t like Perl/CGI? Don’t want to run start a new process for every user/pageview/roundtrip of your site? Next we’ll do PHP… a couple modified copies of lookup.cgi and/or cia.cgi + some HTML glue  fairly interesting site a couple modified copies of lookup.cgi and/or cia.cgi + some HTML glue  fairly interesting site

M.P. Johnson, DBMS, Stern/NYU, Spring Dynamic webpages Original prob: need webpages to respond to user inputs Soln 2:  create a an html file embedded with special non- html code  upon url request, execute embedded code to generate more html/fill in the file  Send back the modified html page to user  An incomplete html page exists on server  Examples: PHP, JSPs, ASPs, etc.

M.P. Johnson, DBMS, Stern/NYU, Spring Review: dynamic webpages First option: for each request: run program, produce whole page, send back  CGI & some host language, Java Servlets, etc. Second option: create html page with missing parts; for each response, fill in the wholes and send back  Embedded scripting  PHP and others  PHP = Personal Home Page or = PHP Hypertext Processor

M.P. Johnson, DBMS, Stern/NYU, Spring hello.php Q: What the difference between and \n? Hello from PHP Here is the PHP part: \n“; ?> That's it! Hello from PHP Here is the PHP part: \n“; ?> That's it!

M.P. Johnson, DBMS, Stern/NYU, Spring hello2.php Script errors, w/ and w/o display_errors on:   Local dir must contain.htaccess:  Automatically load GET/POST params as vars  php_flag display_errors on php_flag register_globals on php_flag display_errors on php_flag register_globals on

M.P. Johnson, DBMS, Stern/NYU, Spring For next time… 1. Run/read these Perl scripts:

M.P. Johnson, DBMS, Stern/NYU, Spring For next time… 2.Run/read these PHP scripts: Various others in dbms/perl and dbms/php…dbms/perldbms/php