Download presentation
Presentation is loading. Please wait.
Published byPhebe Washington Modified over 9 years ago
1
© Anselm Spoerri Web Design Information Visualization Course Prof. Anselm Spoerri aspoerri@rutgers.edu
2
© Anselm Spoerri Lecture 11 – Overview Forms in HTML MySQL & PHP code Sample files have been uploaded to Sakai > Resources > PHP Files –Browse View –Gigapan (practiced in Short Assignment 2) | Photosynth | Video –Attach Hyperlink to Thumbnail to Link to Individual Item page –Individual Item based on supplied id –Gigapan | Photosynth | Video –Dynamic Browse Page based on supplied parameters in URL –SQL Query to support Browse page –How to Extract Parameters in URL –Dynamic Browse Page with Menus –Menus for specifying Query Parameters
3
© Anselm Spoerri HTML Forms ‒ Solicit feedback or information from visitors ‒ Collection of data entry fields, labels, buttons ‒ Processing script on server (PHP) ‒ Never assume anything about data
4
© Anselm Spoerri HTML Form – Form Tag 1. form elements 2.Inside tag –method attribute specifies way in which data is to be sent –method="get" (limited data amount) method="post" –action attribute specifies URL to which user data is to be sent 3.label and form element First Name:
5
© Anselm Spoerri HTML Form – Form Elements and Organization Form Elements Text Field Text Area text Password Radio Button Yes Checkbox Menu Kia Submit Button Reset Button name needed to reference input element Organize Form Elements Legend Text Form Elements
6
© Anselm Spoerri Form Example http://whereru.rutgers.edu/iti320su13/PHPfiles/lec11/browseMenusLinks_spoerri.php $actionString = "browseMenusLinks_spoerri.php" // this.form.submit is used that the page gets updated when the form is changed Campus All New Brunswick Newark Camden
7
© Anselm Spoerri SQL Query to support Browse page Want to be able to search by Type, Campus, Category How? Database Table: $db_table = 'whereru_all'; // description in Sakai Resources Select $query = "SELECT * FROM $db_table WHERE type='gigapan' AND campus='Newark' AND category='Architecture & History' ORDER BY date_created DESC ";
8
© Anselm Spoerri Dynamic Browse Page browse.php ? type=gigapan & campus=Newark & category=Athletics databaseConnect_browse_general_spoerri.php?type=gigapan&campus=New%20Brunswick&category=Athletics extract($_GET, EXTR_PREFIX_ALL, 'fromget'); if (!$fromget_type) { $fromget_type = 'gigapan'; } if (!$fromget_campus) { $fromget_campus = 'New Brunswick'; } if (!$fromget_category) { $fromget_category = 'Architecture & History'; } if (!$fromget_page) { $fromget_page = 1; } SQL Query: $query = "SELECT * FROM $db_table WHERE type= \" $fromget_type \" AND campus= \" $fromget_campus \" AND category= \" $fromget_category \" ORDER BY date_created DESC";
9
© Anselm Spoerri Dynamic Browse Page with Menus http://whereru.rutgers.edu/iti320su13/PHPfiles/lec11/browseMenusLinks_spoerri.php $actionString = "browseMenusLinks_spoerri.php"; // "browseMenusLinks_lastname.php"; extract($_GET, EXTR_PREFIX_ALL, 'fromget'); Use sanitizeString function to sanitize form data Convert $fromget_campus numerical code into campus name Specify WHERE string component of $query using IF statements Form element with action echo(" "); Read Comments in code
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.