Creating Databases for Web Applications Posting due by next class on project! Lab: using files & work session Class: asp Application object 3-tier, separating.

Slides:



Advertisements
Similar presentations
PHP Form and File Handling
Advertisements

JQuery MessageBoard. Lets use jQuery and AJAX in combination with a database to update and retrieve information without refreshing the page. Here we will.
PHP I.
UFCE8V-20-3 Information Systems Development 3 (SHAPE HK) Lecture 3 PHP (2) : Functions, User Defined Functions & Environment Variables.
Introduction to PHP MIS 3501, Fall 2014 Jeremy Shafer
1 Chapter 12 Working With Access 2000 on the Internet.
Session 6 Server-side programming - ASP. An ASP page is an HTML page interspersed with server-side code. The.ASP extension instead of.HTM denotes server-side.
CIS101 Introduction to Computing Week 05. Agenda Your questions CIS101 Survey Introduction to the Internet & HTML Online HTML Resources Using the HTML.
CIS101 Introduction to Computing
Python and Web Programming
Computer Science 101 Web Access to Databases Overview of Web Access to Databases.
Uploading Files. Why? By giving a user the option to upload a file you are creating an interactive page You can enable users have a greater web experience.
2440: 141 Web Site Administration Web Server-Side Programming Professor: Enoch E. Damson.
 2004 Prentice Hall, Inc. All rights reserved. Chapter 25 – Perl and CGI (Common Gateway Interface) Outline 25.1 Introduction 25.2 Perl 25.3 String Processing.
Christopher M. Pascucci Basic Structural Concepts of.NET Browser – Server Interaction.
CST JavaScript Validating Form Data with JavaScript.
PHP Programming. Topics Background and History of PHP Installation Comments in PHP Variables Conditions Loops Functions File Handling Database Handling.
1 Web Database Processing. Web Database Applications Static Report Publishing a report is prepared from a database application and exported to HTML DB.
JAVASCRIPT HOW TO PROGRAM -2 DR. JOHN P. ABRAHAM UTPA.
Advance web Programming Chapter 3: MySQL Date: 28 April 2014 Advance web Programming Chapter 3: MySQL Date: 28 April 2014 Dr. Mogeeb A. A. Mosleh .
ITD 3194 Web Application Development Chapter 4: Web Programming Language.
WEB DESIGN AND PROGRAMMING Introduction to Javascript.
Tutorial 14 Working with Forms and Regular Expressions.
Chapter 6: Forms JavaScript - Introductory. Previewing the Product Registration Form.
 2003 Prentice Hall, Inc. All rights reserved. CHAPTER 3 JavaScript 1.
CSCI 6962: Server-side Design and Programming Introduction to AJAX.
Server-side Scripting Powering the webs favourite services.
Creating Databases for Web Applications Work session Open Source versus Proprietary important topics HW: finish* projects. Look at final quiz guide. Final.
Creating databases for web applications Play quizzes Testing process regular expressions: form validation PHP coding handling forms Homework: regular expressions.
1 PHP and MySQL. 2 Topics  Querying Data with PHP  User-Driven Querying  Writing Data with PHP and MySQL PHP and MySQL.
NMED 3850 A Advanced Online Design January 26, 2010 V. Mahadevan.
10 Adding Interactivity to a Web Site Section 10.1 Define scripting Summarize interactivity design guidelines Identify scripting languages Compare common.
Creating Databases Uploading Files. Reading & writing files. Homework: Starting planning ‘original’ project.
Client Scripting1 Internet Systems Design. Client Scripting2 n “A scripting language is a programming language that is used to manipulate, customize,
Class 1Intro to Databases Goals of this class Understand the architecture behind web database applications Gain a basic understanding of what relational.
Creating Databases for Web Applications cookie examples lab time: favorites cookies & Sessions class time for group work/questions on projects Next class:
CS146 Database Systems &Team Projects Spring 2009.
Creating Dynamic Web Pages Using PHP and MySQL CS 320.
Extending HTML CPSC 120 Principles of Computer Science April 9, 2012.
 2003 Prentice Hall, Inc. All rights reserved. CHAPTER 3 JavaScript 1.
Active Server Pages  In this chapter, you will learn:  How browsers and servers interacted on the Internet when the Internet first became popular 
Mr. Justin “JET” Turner CSCI 3000 – Fall 2015 CRN Section A – TR 9:30-10:45 CRN – Section B – TR 5:30-6:45.
Website Development with PHP and MySQL Saving Data.
Overview: 1. Discussion of the basic architecture of a web application. 2. Discussion of the relevance of using MySQL and PHP in a web application.
Variables and ConstantstMyn1 Variables and Constants PHP stands for: ”PHP: Hypertext Preprocessor”, and it is a server-side programming language. Special.
Dynamic web content HTTP and HTML: Berners-Lee’s Basics.
Creating Databases Local storage. join & split Classwork: show 1 table application. Share designs for oscars application. Adaptive select. Homework: [Catch.
Creating Web Documents: How the Web works Client / Server Protocols Access methods Homework: Complete experiment & report on Discussion Forum.
ASP (Active Server Pages) by Bülent & Resul. Presentation Outline Introduction What is an ASP file? How does ASP work? What can ASP do? Differences Between.
Creating Web Documents catch-up JavaScript slide show tools redirection.
ASP. What is ASP? ASP stands for Active Server Pages ASP is a Microsoft Technology ASP is a program that runs inside IIS IIS stands for Internet Information.
David Lawrence 7/8/091Intro. to PHP -- David Lawrence.
IS-907 Java EE World Wide Web - Overview. World Wide Web - History Tim Berners-Lee, CERN, 1990 Enable researchers to share information: Remote Access.
4. Javascript M. Udin Harun Al Rasyid, S.Kom, Ph.D Lab Jaringan Komputer (C-307) Desain.
Creating Databases for Web applications Server side vs client side PHP basics Homework: Get your own versions of sending working: both html and Flash!
8 Chapter Eight Server-side Scripts. 8 Chapter Objectives Create dynamic Web pages that retrieve and display database data using Active Server Pages Process.
HTML Forms.
Creating Databases for Web Applications 3-Tier. Design vs Function vs Content. More SQL. More php. Homework: work on final projects.
Creating Web Documents: JavaScript Ftp / file management: review Introduction to JavaScript Sources Homework: start review for midterm, work on Project.
Creating Databases applications for the Web: week 2 Basic HTML review, forms HW: Identify unique source for asp, php, Open Source, MySql, Access.
Web Design Terminology Unit 2 STEM. 1. Accessibility – a web page or site that address the users limitations or disabilities 2. Active server page (ASP)
INTERNET APPLICATIONS CPIT405 Forms, Internal links, meta tags, search engine friendly websites.
CGS 3066: Web Programming and Design Spring 2016 PHP.
Web Services Essentials. What is a web service? web service: software functionality that can be invoked through the internet using common protocols like.
ASP – Web Programming Class  Ravi Anand. ASP – Active Server Pages What is ASP? - Microsoft Technology - Can Run using IIS/PWS/Others - Helps us create.
Dreamweaver – Setting up a Site and Page Layouts
Introduction to Dynamic Web Programming
Creating Databases Local storage. join & split
Server-Side Application and Data Management IT IS 3105 (Spring 2010)
Tutorial 10: Programming with javascript
Presentation transcript:

Creating Databases for Web Applications Posting due by next class on project! Lab: using files & work session Class: asp Application object 3-tier, separating design & content Homework: Decide on project. Next week: Initial presentation (diagrams)

Files (aka flat files) php & asp example of reading and appending (adding at the end) to a flat file regular expression replace function to determine complete path for file

Modes asp: 1 (default) for read, 8 for append (will NOT create new file), –2 is for write php: r for read, a for append (creates a new file if none exists), – w for write (creates a new file, discards old contents), – r+ read and write, –w+ read and write AND create new file, discard old contents before writing, –a+ read and append (create new)

Working with a record how to explode / split up a string into an array of elements based on a defined delimiter: –"Curley, Moe, Larry"  Array where 0 th element is "Curley", 1 st element is "Moe", 2 nd element is "Larry" –php: $arr = explode(",", $stringname); –asp: arr = stringname.split(",");

Demonstrate on sharon filetest.php filetest.asp Note: both scripts use the same file. It is created by the filetest.php script the first time. You could also upload a file using ws-ftp. NOTE: on home computer, needed to create empty file in NotePad, find it (from My computer), left click, choose properties and deselect Archive.

Where's the file? In each case, need to do something to get to the file, even if it is in the same folder as the script file. Get the system variable that indicates where the script file is. Alter it (using regular expression replace function) to be the complete path to the file.

Organization of both scripts define 3 functions: displayfile handleform displayform if form submitted then handleform (append to file) else displayfile (read from file) displayform

File reading & writing <?php $abspath = $PATH_TRANSLATED; $stub=ereg_replace("\\filetest.php","\\",$abspath); $filen = $stub. "scores.txt"; function displayfile() { global $filen; $open if ($open) { ?> Player Score <? $filecontents = file($filen); for ($n=0;$n<count($filecontents);$n++) { $record = explode(",",$filecontents[$n]); print (" ".$record[0]." "); print (" ".$record[1]." \n"); } print(" "); fclose($open); $ok = TRUE; } else {$ok = FALSE;} return $ok; } replacing slash followed by known name with slash

function handleform(){ global $player; global $score; global $filen; $open=fopen($filen,"a"); if ($open) { fwrite($open,"$player,$score\n"); fclose($open); $ok=TRUE; } else {$ok=FALSE; } return $ok; } function displayform() { ?> Player handle Score <? } comma part of output

if { if (handleform()) { print("entry made"); } else {print ("entry not made"); } else { if (!displayfile()){ print ("NO PLAYER SCORES ");} displayform(); } ?>

Comments Using these functions is a neat way to compartmentalize actions. Functions could be put in files to be included (require/include). on to asp

File reading & writing <% var abspath=String(Request.ServerVariables("PATH_TRANSLATED")); var filepath=abspath.replace(/\\\w*\.asp/,"\\") + "scores.txt"; function displayfile() { fso=new ActiveXObject("Scripting.FileSystemObject"); file_stream=fso.OpenTextFile(filepath); %> Player Score <% ok = false; while (!file_stream.AtEndOfStream) { ok = true; record = file_stream.ReadLine(); recorda = record.split(","); Response.Write(" " + recorda[0]+ " "); Response.Write(" "+recorda[1] +" \n"); } Response.Write(" "); file_stream.close(); return ok; } \w*\ any number of alphanumerics

function handleform(){ ok = true; var player = String(Request("player")); var score = String(Request("score")); fso=new ActiveXObject("Scripting.FileSystemObject"); file_stream=fso.OpenTextFile(filepath, 8); // 8 for append file_stream.Write(player + "," + score + "\n"); return ok; }

function displayform() { %> Player handle Score <% }

var submitted = String(Request("submitted")); if (submitted!="undefined") { if (handleform()) { Response.Write("entry made"); } else {Response.Write ("entry not made"); } else { if (!displayfile()){ Response.Write ("NO PLAYER SCORES ");} displayform(); } %>

Files vs. database Files are cheaper, no special installation. Use when the data is simple, that is, just one table with few fields OR use when data is complex, many links, many variable length fields AND/OR performance & space are critical Databases provide many functions for tables of data, but at a cost.

Uploading files Allow site user to upload file Appropriate for applications such as in inputproducts that involves citing an image file for each product php implementation HTML

File upload test <?php if { print ("uploading file named $file_name "); print ("File size is $file_size "); $abspath = $PATH_TRANSLATED; $stub=ereg_replace("\\fileupload.php","\\",$abspath); $fullname = $stub. $file_name; print ("fullname is: $fullname. "); if (copy($file,$fullname)) { print ("file successfully uploaded. "); } else { print ("file could not be copied."); } unlink($file); } print (" upload a file to the server \n"); ?> File need a path with name

asp Application object Maintained by system across all users (all sessions). Example (not fully tested) In global.asa file, OnStart routine: set and initialize application variables. In code, store and retrieve Application.Lock; Application("hitcounter") = Application("hitcounter") + 1; Application.Unlock; In global.asa file, also can set OnEnd routine no php equivalent –use data base!

Recall: my terms 3 levels of language: –HTML (text to be interpreted by the browser) –php OR asp and JavaScript –SQL Really more complicated: for example, what is the interpreter of the include/require command? Useful to distinguish 'who' is audience for a fragment of code.

Data base idea: 3 tier view of systems operation –interface/display processor –business logic processor –data base management processor This does correspond to –client computer interpreting HTML –server computer interpreting php or asp –MySql engine or Access engine operating the data base management system

display versus content implementation –what the content is –how content is presented Recent 'new thing' –Use extended markup language XML to specify form of content and the content itself. –Use extended style language XSL and extended style language transform XSLT to specify the look. One use of this could be to have web pages show up appropriately on a computer and on a cell phone type of device.

Comments Dividing task into subtasks is good…but there are associated costs. XML also has role in B2B transactions (followon to EDI for supplier/vendor communications) php/XML and asp/XML connections appear to be still in development stage

Homework Post proposal for project –May be team of 2. From more, more is expected. Next class: time to work on projects and also catch up doing practice scripts. Next week: –present (1 st draft of) ER diagram and process diagram of your project. Prepare hardcopy to turn in. –Use this time to get feedback on project.