Website Development Registering Users – Introducing Cookies.

Slides:



Advertisements
Similar presentations
LIS651 lecture 3 taming PHP Thomas Krichel
Advertisements

LIS651 lecture 3 functions & sessions Thomas Krichel
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.
UFCE8V-20-3 Information Systems Development 3 (SHAPE HK)
Cookies, Sessions. Server Side Includes You can insert the content of one file into another file before the server executes it, with the require() function.
Website Development Database Issues. : Customer browser request service access page interpret set data present html return html get data databasescripting.
Website Development Introducing PHP The PHP scripting language Syntax derives from C, Java and Perl Open Source Links to MySql database.
1 Software Testing and Quality Assurance Lecture 33 – SWE 205 Course Objective: Basics of Programming Languages & Software Construction Techniques.
XP Tutorial 9 New Perspectives on JavaScript, Comprehensive1 Working with Cookies Managing Data in a Web Site Using JavaScript Cookies.
Website Development Working with MySQL. What you will achieve today! Connecting to mySql Creating tables in mySql Saving data on a server using mySql.
Chapter 10 Maintaining State Information Using Cookies.
PHP Tutorials 02 Olarik Surinta Management Information System Faculty of Informatics.
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.
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.
Comp2513 Forms and CGI Server Applications Daniel L. Silver, Ph.D.
PHP Hypertext PreProcessor. Documentation Available SAMS books O’Reilly Books.
A little PHP. Enter the simple HTML code seen below.
Web Programming Language Week 7 Dr. Ken Cosh Security, Sessions & Cookies.
COMP3121 E-Commerce Technologies Richard Henson University of Worcester November 2011.
Creating Databases for Web Applications cookie examples lab time: favorites cookies & Sessions class time for group work/questions on projects Next class:
Chapter 8 Cookies And Security JavaScript, Third Edition.
JavaScript – Quiz #9 Lecture Code:
12/3/2012ISC329 Isabelle Bichindaritz1 PHP and MySQL Advanced Features.
School of Computing and Information Systems CS 371 Web Application Programming PHP – Forms, Cookies, Sessions and Database.
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.
Nic Shulver, Introduction to Sessions in PHP Sessions What is a session? Example Software Software Organisation The login HTML.
Website Development with PHP and MySQL Saving Data.
Cookies Web Browser and Server use HTTP protocol to communicate and HTTP is a stateless protocol. But for a commercial website it is required to maintain.
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.
Cookies & Session Web Technology
11 1 Cookies CGI/Perl Programming By Diane Zak Objectives In this chapter, you will: Learn the difference between temporary and persistent cookies.
Web Scripting [PHP] CIS166AE Wednesdays 6:00pm – 9:50pm Rob Loy.
Dynamic Programming with PHP (mktime), Cookies, SQL, Authentication.
Intro to PHP IST2101. Review: HTML & Tags 2IST210.
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.
Web Design: Basic to Advanced Techniques Fall 2010 Mondays 7-9pm 200 Sutardja-Dai Hall Introduction to PHP.
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.
CP476 Internet Computing CGI1 Cookie –Cookie is a mechanism for a web server recall info of accessing of a client browser –A cookie is an object sent by.
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.
ECMM6018 Enterprise Networking for Electronic Commerce Tutorial 7
How to maintain state in a stateless web Shirley Cohen
PHP and Sessions. Session – a general definition The GENERAL definition of a session in the “COMPUTER WORLD” is: The interactions (requests and responses)
 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 time the same computer requests.
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.
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.
Sessions and cookies (part 2) MIS 3501, Fall 2015 Brad N Greenwood, PhD Department of MIS Fox School of Business Temple University 11/19/2015.
Session 11: Cookies, Sessions ans Security iNET Academy Open Source Web Development.
Programming for the Web Cookies & Sessions Dónal Mulligan BSc MA
© Copyright 2012 Hidaya Trust (Pakistan) ● A Non-Profit Organization ● / www,histpk.org Hidaya Institute of Science & Technology
CHAPTER 5 SERVER SIDE SCRIPTING
A little PHP.
Introduction to Dynamic Web Programming
19.10 Using Cookies A cookie is a piece of information that’s stored by a server in a text file on a client’s computer to maintain information about.
Chapter 19 PHP Part III Credits: Parts of the slides are based on slides created by textbook authors, P.J. Deitel and H. M. Deitel by Prentice Hall ©
Sessions and cookies (part 2)
ITM 352 Cookies.
Web Programming Language
Cookies and Sessions in PHP
Database Driven Websites
<?php require("header.htm"); ?>
Cookies Cookie :- A cookie is often used to identify a user. A cookie is often used to identify a user. A cookie is a small file that the server embeds.
Web Programming Language
Cookies and Sessions.
Web Programming Language
Hypertext Preprocessor
Presentation transcript:

Website Development Registering Users – Introducing Cookies

What you should be able to create at the end of this course A fully working e-commerce site Server side scripting in PHP Saving data on a server using files and MySql

What you will achieve this week! Saving data on the client in cookies How to register and log in users (in a simple way)

: Customer browser request service access page interpret set data present html return html get data databasescripting language web server Reminder of the general process

Registering users data/users : customer registerUser.htmsaveUser.php supply details save *write

Please register User Name Password

<?php $File = fopen("data/users","a"); fwrite($File,sprintf("%s,%s\n", $UserName, $Password)); fclose($File); ?> saveUser.php

What are cookies? A "cookie" is a small piece of information sent by a web server to store on a web browser so it can later be read back from that browser. This is useful for having the browser remember some specific information. What are they used for ? An example is when a browser stores your passwords and user ID's. They are also used to store preferences of start pages, both Microsoft and Netscape use cookies to create personal start pages.

int setcookie (string name [, string value [, int expire ]]) Setcookie() defines a cookie to be sent along with the rest of the header information. Cookies must be sent before any other headers are sent (this is a restriction of cookies, not PHP). This requires you to place calls to this function before any or tags. All the arguments except the name argument are optional. If only the name argument is present, the cookie by that name will be deleted from the remote client. The expire argument is an integer indicating the number of seconds before the cookie expires.

Logging in and validating user name and password

Please provide your account information: User Name Password

include() The include() statement includes and evaluates the specified file. An important note about how this works is that when a file is include()ed, parsing drops out of PHP mode and into HTML mode at the beginning of the target file, and resumes again at the end. For this reason, any code inside the target file which should be executed as PHP code must be enclosed within valid PHP start and end tags.

<?php $found = 0; if (file_exists("data/users")) { $userFile = fopen("data/users","r"); while ($input = fgetcsv($userFile,1000)) { list($u, $p) = $input; if (($u == $UserName) && ($p == $Password)) $found = 1; }; fclose($userFile); }; if ($found) { include('welcome.php'); } else { include('NotRegistered.htm'); }; ?> login.php this will be available as a variable in any future page for this web site

Welcome.php

Sorry, you are not registered as a user, or you have typed your username and password wrongly. Please go to our registration page if you need to register, or to our login page if you think you mistyped. NotRegistered.htm

So, what have we got so far? A means of collecting data from the user A means of transmitting it to the server A means of recording it on the server A means of retrieving data from the server Register users, and allow log in Remember the user on the client using cookies