Creating Databases for Web Applications

Slides:



Advertisements
Similar presentations
Annoucements  Next labs 9 and 10 are paired for everyone. So don’t miss the lab.  There is a review session for the quiz on Monday, November 4, at 8:00.
Advertisements

Programming games Classwork: Show Favorite Sites. Show coin toss. Review concepts. Crooked coin toss. Homework: Complete coin toss examples. Upload files.
Creating Databases for Web Applications State capitals quiz Classwork: design a new quiz Homework: Make sure you can upload files and have MySQL database.
Creating Databases applications for the Web Reprise. Basic HTML review, forms Preview: Server side vs client side Classwork: create HTML forms and check.
Grade Scale Test 1 Results: Average class score after partial credit: __________ Commonly missed questions: #_________________ If you got less than 70%
Creating Databases SELECT. UPDATE. Demonstrate projects. Classwork / Homework: Prepare to choose teams & projects.
JavaScript Form Validation
Creating databases for web applications SQL. Systems design. ER diagrams. Data flow diagrams. Storyboards. Homework: Plan database and applications for.
Avoiding Plagiarism. Quickwrite Come up with a clear thesis statement that answers this question, and then begin to answer it in the form of a freewrite.
Creating databases for Web Applications php basics. ing. phpMyAdmin to set up MySQL. Homework: Use phpMyAdmin. Make posting with [unique] source on.
Creating Databases Local storage. join & split Classwork: show 1 table application. Share designs for oscars application. Adaptive select. Homework: [Catch.
Creating Databases applications for the Web Basic HTML review, forms Preview: Server side vs client side Flash HW: Review HTML forms and FLASH examples.
CSD 340 (Blum)1 Starting JavaScript Homage to the Homage to the Square.
Creating Databases for Web applications Server side vs client side PHP basics Homework: Get your own versions of sending working: both html and Flash!
Creating Databases for Web Applications State capitals quiz: demonstrates parallel structures AND multi-purpose php files Classwork: design a new quiz.
Creating Databases applications for the Web: week 2 Basic HTML review, forms HW: Identify unique source for asp, php, Open Source, MySql, Access.
ASSIGNMENT 2 Salim Malakouti. Ticketing Website  User submits tickets  Admins answer tickets or take appropriate actions.
CompSci 4 Chap 6 Sec 2 Sep 30, 2010 Prof. Susan Rodger “All your troubles are due to those ‘ifs’,” declared the Wizard. If you were not a Flutterbudget.
Creating interfaces Multi-language example Definition of computer information system VoiceXML example Project proposal presentations Homework: Post proposal,
Creating Databases for Web applications Making a table of table information. Reprise on database design. SQL. Classwork/Homework: Projects! Postings.
Programming Games Reprise Credit Cards! Reprise Binary. Overall time limit, setTimeout Homework: [Show virtual something.] Make proposal as reply to my.
A little PHP. Enter the simple HTML code seen below.
Copyright © 2014 Pearson Addison-Wesley. All rights reserved. 4 Simple Flow of Control.
Creating Databases for Web applications
Creating databases for Web Applications
Creating Databases applications for the Web
Session 2 Basics of PHP.
CSE 103 Day 20 Jo is out today; I’m Carl
Recap: If, elif, else If <True condition>:
Basic Scheme February 8, 2007 Compound expressions Rules of evaluation
Creating Databases Local storage. join & split
Programming Games Work / finish and show dice game. Extras. Timed events. ftp. index file. Homework: Catch up and do slide show.
Creating Databases Catch up presentations. Reading & writing files. Sessions. Homework: Starting planning ‘original’ project.
How to Write Web Forms By Mimi Opkins.
Classwork: Examine and enhance falling drop(s) or make your own.
Introduction To Repetition The for loop
Creating databases for web applications
EXCEPTION HANDLING IN SERVER CLIENT PROGRAMMING
Android 11: The Calculator Assignment
Debugging and Random Numbers
Chapter 19 PHP Part II Credits: Parts of the slides are based on slides created by textbook authors, P.J. Deitel and H. M. Deitel by Prentice Hall ©
Performance and User Experience Improvements to the ASU/NASA Space Grant Website
>> PHP: Form Processing
How to get data from a form
Topics Introduction to Repetition Structures
Web Programming– UFCFB Lecture 17
HTML/XHTML Forms 18-Sep-18.
Sentinel logic, flags, break Taken from notes by Dr. Neil Moore
While Loops BIS1523 – Lecture 12.
Simple PHP application
HTML Forms and User Input
Web Systems Development (CSC-215)
Number Line Where are you on the learning journey?
Creating Databases SELECT. UPDATE. Demonstrate projects. Do not track.
Sentinel logic, flags, break Taken from notes by Dr. Neil Moore
Creating Databases for Web Applications
Escape sequences: Practice using the escape sequences on the code below to see what happens. Try this next code to help you understand the last two sequences.
Class05 How to get data from a form
Today’s Objectives Week 12 Announcements ASP.NET
Starter answer these questions in your book
Chapter 3: Selection Structures: Making Decisions
HTML Forms 18-Apr-19.
Topics Introduction to Repetition Structures
Programming games Share your plans for your virtual something.
Chapter 3: Selection Structures: Making Decisions
PHP-II.
Mr. Justin “JET” Turner CSCI 3000 – Fall 2016 Section DA MW 4:05-5:20
Agenda for Unit 5: Control Structures
Creating Databases for Web Applications
Programming games Reprise on dice game and alternative dice game
Presentation transcript:

Creating Databases for Web Applications State capitals quiz: demonstrates parallel structures AND multi-purpose php files Classwork: design a new quiz Homework: Make sure you can upload files and have MySQL database. Get a simple quiz working like the state capital quiz. Post unique source on REGULAR expressions. Catch up on postings oh php and MySql. There is a new assignment. Note: you can use regular expressions in your simple quiz.

multi-purpose php files Used to both present a form and check the input in a form. Replacement for html and php pair. Advantages: don’t have to coordinate two files less files to handle Disadvantages need to include coding to make determination

Use of @ sign The @ sign is used to suppress error messages. We will use it in the code to test if something, namely a form input, exists. if it does, then control goes to the code for handling the form otherwise, control goes to the code for displaying the form Also use it to suppress an error when one input is missing

rand Built-in php function. Takes two arguments. rand(a, b), a and b integers, returns random value from a, … b. Check out shuffle, mt_rand. Extra credit posting opportunity to explain. This is how it is done in php. Do try for the extra credit. Must be unique.

State capital quiz http://socialsoftware.purchase.edu/jeanine.meyer/statecapquizask.php Choose what to be asked Note: how can this be worded better???? Ask Check the answer Give chance to try again or Go back to get new question Obvious choice for parallel structures because there are pairs of data. (Of course, this quiz requires exact answers, and doesn't accept abbreviations or minor mis-spellings).

State capitals quiz Implementation: three php files. Two of the php files call themselves and include the other file. statecapitals.php This file is include[d] in the others. It sets up 2 parallel arrays holding the names of the states and the capital cities. statecapquizask.php This is a multi-purpose file. statecapquizcheck.php This is also a multi-purpose file. Checks answer. Allows for another guess or goes back to statecapquizask.php The statecapitals.php file is the data. Call it a data bank.

State capitals storyboard Include file: statecapitals.php statecapquiz.php statecapquizcheck.php Notice: no html files

Programming practices Parallel structures, in this case the array of states corresponding to the array of capitals, is a common programming device. Think of it as an alternative to a database or xml for very simple cases. Repeat: multi-purpose, self-referencing of php scripts is a common practice benefits: reduces number of files. Information in one place negatives: the one file is more complex

statecapitals.php <?php $states = Array(); $capitals = Array(); $states[]="Alabama"; //adds to array $capitals[]="Montgomery"; $states[]="Alaska"; $capitals[]="Juneau"; … I wrote all this!!!

statecapquizask.php <h1>State Capital Quiz </h1><p> <html> <head> <title>State capitals quiz: check</title> </head> <body> <h1>State Capital Quiz </h1><p> <?php $saywhich=@$_GET['saywhich']; if ($saywhich){ include("statecapitals.php"); $which=$_GET['which']; $choice=rand(0, sizeOf($states)-1); If $saywhich is true, meaning it was set, then $which will determine what type of question to ask

$state = $states[$choice]; if ($which=='state') { $state = $states[$choice]; print("What is the capital of $state?<br>"); print("<form action='statecapquizcheck.php' method='get'>\n"); print("<input type='text' name='capital'><br>\n"); print("<input type='hidden' name='which' value=$which>\n"); print("<input type='hidden' name='choice' value=$choice>\n"); print("<input type='submit' value='Submit Answer'>"); print("</form>\n"); } Why should I NOT have used method=get ???

else { $capital = $capitals[$choice]; print("$capital is the capital of which state?<br>"); print("<form action='statecapquizcheck.php' method='get'>\n"); print("<input type='text' name='state'><br>\n"); print("<input type='hidden' name='which' value=$which>\n"); print("<input type='hidden' name='choice' value=$choice>\n"); print("<input type='submit' value='Submit Answer'>"); print("</form>\n"); } }

else { print("Choose form of question: do you want to be given the state or the capital?<br>"); print("<form action='statecapquizask.php' method='get'>\n"); print("Ask <input type='radio' name='which' value='state'>State"); print(" <input type='radio' name='which' value='capital'>Capital\n"); print("<input type='hidden' name='saywhich' value='true'>\n"); print("<input type='submit' value='Submit choice'>"); print("</form>"); } ?> </body> </html>

statecapquizcheck.php <html> <head> <title>State capitals quiz: check</title> </head> <body> <?php include('statecapitals.php'); $choice=$_GET['choice']; $state=@$_GET['state']; $capital=@$_GET['capital']; $which=$_GET['which']; $correctstate=$states[$choice]; $correctcapital=$capitals[$choice];

if ($which=='state') { if ($capital == $correctcapital) { print("Correct! $correctcapital is the capital of $correctstate!"); print("<p><a href='statecapquizask.php'>Play again </a>"); }

print("<input type='text' name='capital'><br>\n"); else { print("WRONG!<p>\n"); print("<a href='statecapquizask.php'>New turn </a><p>\n"); print("OR try again: What is the capital of $correctstate?<br>"); print("<form action='statecapquizcheck.php' method='get'>\n"); print("<input type='text' name='capital'><br>\n"); print("<input type='hidden' name='state' value=$state>\n"); print("<input type='hidden' name='which' value=$which>\n"); print("<input type='hidden' name='choice' value=$choice>\n"); print("<input type='submit' value='Submit Answer'>"); print("</form>\n"); } }

else { if ($state == $correctstate) { print("Correct! The capital of $correctstate is $correctcapital!"); $saywhich='false'; print("<p><a href='statecapquizask.php'>Play again </a>"); }

else { print("WRONG!<p>\n"); print("<a href='statecapquizask.php'>New turn </a><p>\n"); print("OR try again: $correctcapital is the capital of what state?<br>"); print("<form action='statecapquizcheck.php' method='get'>\n"); print("<input type='text' name='state'><br>\n"); print("<input type='hidden' name='capital' value=$capital>\n"); print("<input type='hidden' name='which' value=$which>\n"); print("<input type='hidden' name='choice' value=$choice>\n"); print("<input type='submit' value='Submit Answer'>"); print("</form>\n"); } } ?>

else { $capital = $capitals[$choice]; print("$capital is the capital of which state?<br>"); print("<form action='statecapquizcheck.php' method='get'>\n"); print("<input type='text' name='state'><br>\n"); print("<input type='hidden' name='which' value=$which>\n"); print("<input type='hidden' name='choice' value=$choice>\n"); print("<input type='submit' value='Submit Answer'>"); print("</form>\n"); } }

print("<form action='statecapquizask.php' method='get'>\n"); else { print("Choose form of question: do you want to be given the state or the capital?<br>"); print("<form action='statecapquizask.php' method='get'>\n"); print("Ask <input type='radio' name='which' value='state'>State"); print(" <input type='radio' name='which' value='capital'>Capital\n"); print("<input type='hidden' name='saywhich' value='true'>\n"); print("<input type='submit' value='Submit choice'>"); print("</form>"); } ?> </body></html> So why did I use method=get all those times??? See next.

Reprise if statements within if statements php produces the appropriate html, including the form element The php is printing (producing) html. It is not operating the quiz! There are ways to enhance this program perhaps limit the number of re-tries prevent browser from showing previous inputs see next slide… Answer: pedagogical reasons. I wanted you to see what the form was producing.

Note Answer must be exact! Sometimes this is not appropriate. Consider NOT requiring exact case. Extra credit opportunity Consider something else, such as inexact spelling. What is close enough? How to measure? Use of regular expression is a way to present a pattern of answers as opposed to a set answer. Later: we will cover the use of LIKE as an operator in MySql statements Opportunities for improvement

Classwork (teams) Design simple quiz like the state capital quiz, using parallel arrays for questions and answers Ideas? OR make significant enhancement to my quiz, like adding scoring, limiting re-tries some other quiz! Do this!

Homework Get your quiz working. Post link in posting to the General Discussion Forum. Research and post unique source on Regular expressions on moodle. We use regular expressions to validate input and extract information from input. potential for quizzes. You will need to upload your 3 files.