CS 174: Web Programming January 27 Class Meeting

Slides:



Advertisements
Similar presentations
Powerpoint Templates Page 1 Powerpoint Templates.
Advertisements

Free Powerpoint Templates Page 1 Free Powerpoint Templates Name of Presentation by Mr X.
ALEX SMITH UI/UX DESIGNER, DEVELOPER, ANAYST. ABOUT EDUCATION EXPERIENCE PORTFOLIO CONTACT Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed.
Page 1 Powerpoint Templates Name of presentation by Mr X.
contents Part one add title here Part fore add title here Part two
SQL Capstone Templates
This is the title of your very awesome poster
Course Title |Sub-Title
Company or University Logo
Authors Names / Organization where the paper was developed
Title here ETD presentation title here
Conclusiones / Conclusions
Title Here text description September 2015 Story Title 2-3
Department of Internal Medicine, Etc etc
SQL Capstone Templates
Presented by: Name, Title, CBORD and Co- presenter
Name of Recipe Ingredients Ingredient goes here Ingredient goes here
Regional Humanitarian Response Strategy Reviewed
Presentation Title - Subtitle
SUB HEADLINE.
Research Conference Poster Template – Long title goes here and if needed, here…. (author’s names and University go here) Abstract Lorem ipsum dolor sit.
tsfx program name/year
Conclusiones / Conclusions
Your company informations
Course Title |This is the slide title
TITLE OF THE POSTER Poster ID: Authors Affiliations Abstract
Presentation title here
Department of Internal Medicine, Etc etc
PRESENTATION TITLE Place, date.
SQL Capstone Templates
Click to add title here Click to add subtitle here.
Your company informations
Your company informations
Your company informations
Tabuk City National High School, Dagupan West, Tabuk City, Kalinga
Title of the Research Study
Name of presentation by Mr X.
General Surgical Terms
Your company informations
Four Arrows Title To come Title To come Title To come Title To come.
Page Header Sub-title Title Title First bullet Second bullet
Title Title.
This is Template Presenter: Mr. Bla.
TITLE OF THE POSTER Authors Affiliations Poster ID: Abstract
TITLE Sub Title.
Your company informations
click a topic to start Vector image courtesy of freepik.com.
Your company informations
Name of presentation by Mr X Powerpoint Templates Powerpoint Templates.
PRESENTATION TITLE Presentation Subtitle By James Sager – Dec 31, 2021
Your company informations
Your company informations
Your company informations
… … TITLE: Subtitle Authors: Contact: 1. Introduction 2. Methodology
Name of Recipe Ingredients Directions Ingredient goes here
Title Here text description September 2015 Story Title 2-3
Your company informations
Your company informations
September 2015 Quarry Bowl Title Rocklin vs Whitney.
Your company informations
Your company informations
PRESENTATION SUBTITLE
Anne Frank Dates I learned...
Your company informations
Presentation title: catchy idea enticing the audience’s attention
Your company informations
Your company informations
Presentation transcript:

CS 174: Web Programming January 27 Class Meeting Department of Computer Science San Jose State University Spring 2015 Instructor: Ron Mak www.cs.sjsu.edu/~mak

Project Teams Assignments will be done by small project teams. Form your own teams of 4 members each. Choose your team members wisely! Be sure you’ll be able to meet and communicate with each other and work together well. No moving from team to team.

Project Teams, cont’d Each team member will receive the same score on each team assignment and team project. Each team email to ron.mak@sjsu.edu as soon as possible: Your team name A list of team members and email addresses Subject: CS 174 Team Team Name Example: CS 174 Team Super Coders

Team Project Each team picks a web application to develop during the semester. We’ll start with a very simple application: ` Prompt the user for some input in the first page displayed at the web browser. The user data is sent to the web server. A simple server program uses the user data to query a database table and fetch some information. Display the information to the user in a second web page at the web browser.

Team Project, cont’d As you learn more web software technologies, subsequent assignments will ask each team to add more capabilities to the simple application. Always add new capabilities to an application that’s already working. Spiral approach. By the end of the semester, each team will have successfully developed a significant web application!

Install XAMPP Download and install XAMPP Installs and configures Apache (with PHP) and MySQL in one package. Both Windows and Mac. See: https://www.apachefriends.org/index.html

XAMPP Control Panel Use the XAMPP control panel to start or stop: Apache Web Server MySQL Database Server FTP server

“localhost” Home Page First, you may have to visit http://localhost/xampp/lang.php?en which automatically initializes some pages.

XAMPP Directory Structure Folder htdocs is the root of all the web pages on your web server.

Take roll!

Client-Server Web Apps Client Side Web Browser Chrome Firefox Safari Microsoft IE Server Side Web Server Apache + PHP HTTP request HTTP response HTTP request User’s form data HTTP response Dynamically generated HTML page

Basic “Naked” HTML HTML specifies a web page’s Content Structure Semantics HTML should no longer specify formatting. Separate content from formatting. Formatting tags and attributes are deprecated. Font, color, alignment, etc. Formatting should be specified by CSS. Cascading Style Sheets

HTML Page Template <!DOCTYPE html> <html lang="en-US"> <head> <meta charset="UTF-8"> <title>page title</title> </head> <body> body of page </body> </html>

Paragraphs and Headings <body> <h1>Chapter 1</h1> <h2>Subsection 1.1</h2> <h2>Subsection 1.2</h2> <p> Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. </p> Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum. ... </body>

Paragraphs and Headings, cont’d <body> ... <h2>Subsection 1.3</h2> <h3>Subsection 1.3.1</h3> <h3>Subsection 1.3.2</h3> <h3>Subsection 1.3.3</h3> <p> This is a paragraph. </p> <h1>Chapter 2</h1> Yet another paragraph. </body>

Paragraphs and Headings, cont’d

Ordered and Unordered Lists <body> <h1>Unordered list</h1> <ul> <li>California</li> <li>New York</li> <li>Texas</li> </ul> <h1>Ordered list</h1> <ol> <li>CS 146</li> <li>CS 151</li> <li>CS 152</li> <li>CS 153</li> <li>CS 160</li> <li>CS 174</li> </ol> </body>

Nested Lists <body> <!-- Ignore the following anchor tag for now. --> <a name="nested"></a> <h1>Nested list</h1> <ol> <li> <h2>California</h2> <ul> <li>San Francisco</li> <li>San Jose</li> <li>Los Angeles</li> </ul> </li> <h2>New York</h2> <li>New York City</li> <li>Albany</li> </ol> <h2>Texas</h2> <li>Dallas</li> <li>El Paso</li> </body>

Simple Table <body> <h1>Simple table</h1> <caption>States</caption> <tr> <th>State</th> <th>Capital</th> <th>Population</th> </tr> <td>California</td> <td>Sacramento</td> <td>38,802,500</td> <td>New York</td> <td>Albany</td> <td>19,746,227</td> <td>Texas</td> <td>Austin</td> <td>26,956,958</td> </table> </body>

Table with Borders <body> <h1>Borders</h1> <table border="1"> <caption>States</caption> <tr> <th>State</th> <th>Capital</th> <th>Population</th> </tr> <td>California</td> <td>Sacramento</td> <td>38,802,500</td> <td>New York</td> <td>Albany</td> <td>19,746,227</td> <td>Texas</td> <td>Austin</td> <td>26,956,958</td> </table> </body>

Table with colspan and rowspan <body> <h1>Spanning rows and columns</h1> <table border="1"> <caption>States</caption> <tr> <th>State</th> <th>Capital</th> <th>Population</th> </tr> <td>California</td> <td colspan=2>The Golden State</td> <td>New York</td> <td>Albany</td> <td rowspan=2>Too many!</td> <td>Texas</td> <td>Austin</td> </table> </body>

Links to Pages Demo <body> <h1>Links</h1> <p> An absolute link to the <a href="http://localhost/basics/paragraphs.html"> Paragraphs and Headings </a> page has the complete URL: <strong>http://localhost/examples/paragraphs.html</strong> </p> A relative link to the <a href="tables.html">Tables</a> page has a URL that is relative to the directory of the current page: <strong>tables.html</strong> ... </body> Demo

Links to Anchor Tags Demo <body> ... <h1>Links to Anchor Tags</h1> <p> A link to the the <a href="#lorem">lorem</a> anchor tag on this page uses the location <strong>#lorem</strong>. Place the anchor tag before the line you want to jump to. </p> You can also jump to the <a href="lists.html#nested">nested</a> anchor tag on the Lists page using the location <strong>lists.html#nested</strong> <a name="lorem"></a> <h1>Lorem ipsum</h1> Lorem ipsum dolor sit amet ... </body> Demo

Images <body> <p> An <em>inline image</em> <img src="images/RonCats2a.jpg"/> of my two cats. </p> An inline image <a href="cats.html"><img src="images/RonCats1a.jpg"/></a> can serve as a link! </body> </html>

Images, cont’d Demo

Form Data A user can input data into an HTML form displayed on a client-side web browser. When the user presses a Submit button, the browser sends to form data to a specified PHP program running on the web server. The PHP program can use the form data to Query the back-end database. Generate a new HTML page to send to the user’s client-side web browser.

Text Input: HTML Page <body> <form action="text.php" method="get"> <fieldset> <legend>User input</legend> <p> <label>First name:</label> <input name="firstName" type="text" /> </p> <label>Last name:</label> <input name="lastName" type="text" /> <input type="submit" value="Submit" /> </fieldset> </form> </body>

Text Input: PHP Code Demo <!DOCTYPE html> <html lang="en-US"> <head> <meta charset="UTF-8"> <title>Text Greeting</title> </head> <body> <p> <?php $first = filter_input(INPUT_GET, "firstName"); print "<h1>Hello, $first!</h1>"; ?> </p> </body> </html> Demo

Checkbox Input: HTML Page <body> <form action="checkbox.php" method="post"> <fieldset> ... <p> <label>Any formatting?</label> <input type="checkbox" name="strong" value="strong" /> Strong! name="em" value="em" /> Emphasized! </p> </fieldset> </form> </body>

Checkbox Input: PHP Code <body> <p> <?php $first = filter_input(INPUT_POST, "firstName"); $output = "Hello, $first!"; if (filter_has_var(INPUT_POST, "strong")) { $output = "<strong>$output</strong>"; } if (filter_has_var(INPUT_POST, "em")) { $output = "<em>$output</em>"; print $output; ?> </p> </body> Demo

Radio Button Input: HTML Page <body> <form action="radio.php" method="post"> <fieldset> ... <p> <label>Direction></label> <input type="radio" name="direction" value="coming" checked /> Coming value="going" /> Going </p> </fieldset> </form> </body> Every radio button in the same group must have the same name (e.g., direction).

Radio Button Input: PHP Code <body> <p> <?php $first = filter_input(INPUT_POST, "firstName"); $direction = filter_input(INPUT_POST, "direction"); if ($direction == "coming") { $output = "Hello"; } else if ($direction == "going") { $output = "Good-bye"; else { $output = "You are SO confused"; $output = $output.", $first!"; ... print $output; ?> </p> </body> Demo

Select List Input: HTML Page <body> <form action="select.php" method="post"> <fieldset> ... <p> <label>Language?</label> <select name="language"> <option value="english" selected>English</option> <option value="french">Français</option> <option value="german">Deutsch</option> </selct> </p> <input type="submit" value="Submit" /> </fieldset> </form> </body>

Select List Input: PHP Code <body> <p> <?php $first = filter_input(INPUT_POST, "firstName"); $direction = filter_input(INPUT_POST, "direction"); $language = filter_input(INPUT_POST, "language"); $error = "You are SO confused"; if ($direction == "coming") { switch ($language) { case "english": $output = "Hello"; break; case "french": $output = "Bonjour"; case "german": $output = "Guten tag"; default: $output = $error; } else if ($direction == "going") { $output = "Good-bye"; $output = "Au revoir"; $output = "Auf wiedersehen"; else { ... ?> </p> </body> Select List Input: PHP Code Demo