Web Scripting [PHP] CIS166AE Wednesdays 6:00pm – 9:50pm Rob Loy.

Slides:



Advertisements
Similar presentations
PHP: Date() Function The PHP date() function formats a timestamp to a more readable date and time.
Advertisements

Copyright © 2003 Pearson Education, Inc. Slide 8-1 The Web Wizards Guide to PHP by David Lash.
PHP II Interacting with Database Data. The whole idea of a database-driven website is to enable the content of the site to reside in a database, and to.
PHP Hypertext Preprocessor Information Systems 337 Prof. Harry Plantinga.
By Brian Vees.  SQL Injection  Username Enumeration  Cross Site Scripting (XSS)  Remote Code Execution  String Formatting Vulnerabilities.
Manipulating MySQL Databases with PHP. PHP and mySQL2 Objectives Connect to MySQL from PHP Learn how to handle MySQL errors Execute SQL statements with.
Intermediate PHP & MySQL
Chapter 9 Collecting Data with Forms. A form on a web page consists of form objects such as text boxes or radio buttons into which users type information.
Lecture 3 – Data Storage with XML+AJAX and MySQL+socket.io
© Yanbu University College YANBU UNIVERSITY COLLEGE Management Science Department © Yanbu University College Module 6:WEB SERVER AND SERVER SIDE SCRPTING,
Session 5: Working with MySQL iNET Academy Open Source Web Development.
Open Source Server Side Scripting ECA 236 Open Source Server Side Scripting Cookies & Sessions.
Cookies Set a cookie – setcookie() Extract data from a cookie - $_COOKIE Augment user authentication script with a cookie.
MySQL in PHP – Page 1 of 17CSCI 2910 – Client/Server-Side Programming CSCI 2910 Client/Server-Side Programming Topic: MySQL in PHP Reading: Williams &
CHAPTER 12 COOKIES AND SESSIONS. INTRO HTTP is a stateless technology Each page rendered by a browser is unrelated to other pages – even if they are from.
PHP Hypertext PreProcessor. Documentation Available SAMS books O’Reilly Books.
NMED 3850 A Advanced Online Design January 26, 2010 V. Mahadevan.
Web Programming: Client/Server Applications Server sends the web pages to the client. –built into Visual Studio for development purposes Client displays.
CS 3630 Database Design and Implementation. Your Oracle Account UserName is the same as your UWP username Followed Not case sensitive Initial.
Web Programming Language Week 7 Dr. Ken Cosh Security, Sessions & Cookies.
Creating Databases for Web Applications cookie examples lab time: favorites cookies & Sessions class time for group work/questions on projects Next class:
12/3/2012ISC329 Isabelle Bichindaritz1 PHP and MySQL Advanced Features.
15/10/20151 PHP & MySQL 'Slide materials are based on W3Schools PHP tutorial, 'PHP website 'MySQL website.
Installing and Using MySQL and phpMyAdmin. Last Time... Installing Apache server Installing PHP Running basic PHP scripts on the server Not necessary.
PHP MySQL Introduction. MySQL is the most popular open-source database system. What is MySQL? MySQL is a database. The data in MySQL is stored in database.
Creating Dynamic Web Pages Using PHP and MySQL CS 320.
School of Computing and Information Systems CS 371 Web Application Programming PHP – Forms, Cookies, Sessions and Database.
Web Scripting [PHP] CIS166AE Wednesdays 6:00pm – 9:50pm Rob Loy.
MySQL Databases & PHP Integration Using PHP to write data to, and retrieve data from, a MySQL database.
NMED 3850 A Advanced Online Design January 12, 2010 V. Mahadevan.
Week seven CIT 354 Internet II. 2 Objectives Database_Driven User Authentication Using Cookies Session Basics Summary Homework and Project 2.
Lecture 8 – Cookies & Sessions SFDV3011 – Advanced Web Development 1.
Website Development with PHP and MySQL Saving Data.
1 Chapter 9 – Cookies, Sessions, FTP, and More spring into PHP 5 by Steven Holzner Slides were developed by Jack Davis College of Information Science.
PHP Workshop ‹#› Maintaining State in PHP Part II - Sessions.
CSC 2720 Building Web Applications Server-side Scripting with PHP.
Intro to DatabasesClass 4 SQL REVIEW To talk to the database, you have to use SQL SQL is used by many databases, not just MySQL. SQL stands for Structured.
SessionsPHPApril 2010 : [‹#›] Maintaining State in PHP Part II - Sessions.
Dynamic Programming with PHP (mktime), Cookies, SQL, Authentication.
CIS166AE : PHP Web Scripting Rob Loy. Tonight’s Agenda Housekeeping items Housekeeping items PHP basics PHP basics Student connection to server Student.
COOKIES and SESSIONS. COOKIES A cookie is often used to identify a user. A cookie is a small file that the server embeds on the user's computer. Each.
Controlling Web Site Access Using Logins CS 320. Basic Approach HTML form a php page that collects the username and password  Sends them to second PHP.
Web Scripting [PHP] CIS166AE Wednesdays 6:00pm – 9:50pm Rob Loy.
NMD202 Web Scripting Week5. What we will cover today PHP & MySQL Displaying Dynamic Pages Exercises Modifying Data PHP Exercises Assignment 1.
Web Scripting [PHP] CIS166AE Wednesdays 6:00pm – 9:50pm Rob Loy.
Creating a simple database This shows you how to set up a database using PHPMyAdmin (installed with WAMP)
8 Chapter Eight Server-side Scripts. 8 Chapter Objectives Create dynamic Web pages that retrieve and display database data using Active Server Pages Process.
Chapter 8 Manipulating MySQL Databases with PHP PHP Programming with MySQL 2 nd Edition.
How to maintain state in a stateless web Shirley Cohen
Sessions Brendan Knight A visitor accessing your web site is assigned a unique id. This id links to specific data that remains on the server. Sessions.
Web Scripting [PHP] CIS166AE Wednesdays 6:00pm – 9:50pm Rob Loy.
Class 3Intro to Databases Class 4 Simple Example of a Database We’re going to build a simple example of a database, which will allow us to register users.
ITM © Port,Kazman 1 ITM 352 Cookies. ITM © Port,Kazman 2 Problem… r How do you identify a particular user when they visit your site (or any.
1 PHP HTTP After this lecture, you should be able to know: How to create and process web forms with HTML and PHP. How to create and process web forms with.
Introduction to MySQL Ullman Chapter 4. Introduction MySQL most popular open-source database application Is commonly used with PHP We will learn basics.
Web Page Designing With Dreamweaver MX\Session 1\1 of 9 Session 3 PHP Advanced.
Cookies and Sessions in PHP. Arguments for the setcookie() Function There are several arguments you can use i.e. setcookie(‘name’, ‘value’, expiration,
Unit-6 Handling Sessions and Cookies. Concept of Session Session values are store in server side not in user’s machine. A session is available as long.
Session 11: Cookies, Sessions ans Security iNET Academy Open Source Web Development.
PHP – Hypertext Preprocessor.
CS 3630 Database Design and Implementation
Introduction to Dynamic Web Programming
CIIT-Human Computer Interaction-CSC456-Fall-2015-Mr
CIIT-Human Computer Interaction-CSC456-Fall-2015-Mr
Web Design and Development
Web Programming Language
Cookies and Sessions in PHP
Web Programming Language
PHP-II.
Presentation transcript:

Web Scripting [PHP] CIS166AE Wednesdays 6:00pm – 9:50pm Rob Loy

Agenda Presentations Presentations Overview of existing pages and functionality Overview of existing pages and functionality SQL sort SQL sort Creating mysql tables Creating mysql tables PHP security infrastructure PHP security infrastructure Mid-term Project Mid-term Project In class work: Sessions In class work: Sessions

Lab 3 Create folder “class5” Create folder “class5” Copy week4 files into week5 Copy week4 files into week5 Update index.php to display all the information. The information should be displayed in an format. Update index.php to display all the information. The information should be displayed in an format. Update update.php to allow age to be updated Update update.php to allow age to be updated Send to with URL to input form file before 6pm on October 10. Send to with URL to input form file before 6pm on October

Sort DB records SELECT * FROM persons ORDER BY fname ASC; SELECT * FROM persons ORDER BY fname ASC; SELECT * FROM persons ORDER BY fname DESC; SELECT * FROM persons ORDER BY fname DESC; The ORDER BY keyword is used to sort the result-set by a specified column. The ORDER BY keyword is used to sort the result-set by a specified column. The ORDER BY keyword sort the records in ascending order by default. The ORDER BY keyword sort the records in ascending order by default. If you want to sort the records in a descending order, you can use the DESC keyword. If you want to sort the records in a descending order, you can use the DESC keyword.

phpMyAdmin

mySQL Data Types Numeric Numeric Float Float Integer Integer String String Char Char Varchar Varchar Text Text Date Date

Create mySQL Table Structure Name each field Name each field Select a Type Select a Type Assign a length for VARCHAR or CHAR types Assign a length for VARCHAR or CHAR types Design default values Design default values Determine if NULL values allowed by using NULL checkbox Determine if NULL values allowed by using NULL checkbox Pick one field as ID and select INT type and A_I checkbox Pick one field as ID and select INT type and A_I checkbox

PHP Global Variables $_POST $_POST $_GET $_GET $_SESSION $_SESSION $_COOKIES $_COOKIES

Cookies A cookie is a small file that is stored on the client computer when visiting a website. Stored on the client computer Stored on the client computer Lifespan set when created Lifespan set when created Work well with large sites that use several Web servers Work well with large sites that use several Web servers No good if the client has disabled cookies No good if the client has disabled cookies Can be edited since they reside on the client system Can be edited since they reside on the client system

How to use Cookies // Set a cookie for one hour setcookie("TestCookie", “YAY", time()+3600); // Get cookie information echo $_COOKIE["TestCookie"];echo $HTTP_COOKIE_VARS["TestCookie"]; // Delete cookies setcookie ("TestCookie", "", time() );setcookie ("TestCookie", "");

Sessions Sessions are a combination of a server-side cookie and a client-side cookie, where the client-side cookie is simply a reference id to the information stored in the server-side cookie. Server-size cookie can store large amounts Server-size cookie can store large amounts Data is stored on the server Data is stored on the server Only last until the user closes their browser Only last until the user closes their browser

How to use Sessions // Have to start session before any output session_start(); // Set the variable for page session $_SESSION['favcolor'] = 'green'; // Get the session variable information echo $_SESSION[‘favcolor’]; // Finally, destroy the session.unset($_SESSION[“favcolor”]);session_destroy();

IMPORTANT NOTE To use cookie-based sessions, session_start() must be called before outputting anything to the browser.

Security model LOGIN PAGE SECURED PAGE If username and password combination are in DB then “TRUE” else “FALSE” TRUEFALSE SELECT * FROM users WHERE username=‘bob’ AND password =‘mypass’; Not logged in

Security test if ($_SESSION[“status”] !== “Active”) {header(“Location:login.php”);} if (mysql_num_rows($object) == 1) { $_SESSION[“status”] = “Active”; } login.php secure.php

Questions?

Lab 4 Make sure clas files are working for : Make sure clas files are working for : index.php index.php signin.php signin.php signout.php signout.php Username (rob) and Password (.rob) Username (rob) and Password (.rob) Send to with URL to input form file before 6pm on October 17. Send to with URL to input form file before 6pm on October 17.

Mid-term Project Create folder called project1 Create folder called project1 Create mySQL table that has at least 5 fields Create mySQL table that has at least 5 fields SELECT all records from the table SELECT all records from the table Create a web form that has INSERT and UPDATE functionality for the table Create a web form that has INSERT and UPDATE functionality for the table Add a two-way sort functionality Add a two-way sort functionality At least TWO fields have to be required and display error messages At least TWO fields have to be required and display error messages Send to with URL to file before 6pm on October 24. Send to with URL to file before 6pm on October 24.