Presentation is loading. Please wait.

Presentation is loading. Please wait.

Web Design and Development

Similar presentations


Presentation on theme: "Web Design and Development"— Presentation transcript:

1 Web Design and Development
Lecture # 11 Session And Login Instructor: Rida Noor Department of Computer Science

2 * 07/16/96 PHP Session (c) 2007 National Academy for Software Development - All rights reserved. Unauthorized copying or re-distribution is strictly prohibited.*

3 What is a PHP Session? * 07/16/96 A normal HTML website will not pass data from one page to another. In other words, all information is forgotten when a new page is loaded. This makes it quite a problem for tasks like a shopping cart, which requires data(the user's selected product) to be remembered from one page to the next. Session variables solve this problem by storing user information to be used across multiple pages (e.g. username, favorite color, etc). By default, session variables last until the user closes the browser. (c) 2007 National Academy for Software Development - All rights reserved. Unauthorized copying or re-distribution is strictly prohibited.*

4 * 07/16/96 Session Session variables hold information about one single user, and are available to all pages in one application. (c) 2007 National Academy for Software Development - All rights reserved. Unauthorized copying or re-distribution is strictly prohibited.*

5 Start a PHP Session * 07/16/96 A session is started with the session_start() function. Session variables are set with the PHP global variable: $_SESSION. Now, let's create a new page called “startSession.php". In this page, we will start a new PHP session and set some session variables: (c) 2007 National Academy for Software Development - All rights reserved. Unauthorized copying or re-distribution is strictly prohibited.*

6 Start a PHP Session Browser Result: * 07/16/96
(c) 2007 National Academy for Software Development - All rights reserved. Unauthorized copying or re-distribution is strictly prohibited.*

7 Get PHP Session Variable Values
* 07/16/96 Browser Result: (c) 2007 National Academy for Software Development - All rights reserved. Unauthorized copying or re-distribution is strictly prohibited.*

8 Get PHP Session Variable Values
* 07/16/96 We created another page called “getSessionValues.php". From this page, we accessed the session information we set on the first page (" startSession.php"). Notice that session variables are not passed individually to each new page, instead they are retrieved from the session we open at the beginning of each page (session_start()). Also notice that all session variable values are stored in the global $_SESSION variable: (c) 2007 National Academy for Software Development - All rights reserved. Unauthorized copying or re-distribution is strictly prohibited.*

9 Destroy a PHP Session * 07/16/96 To remove all global session variables and destroy the session, use session_unset() and session_destroy(): Browser Result: (c) 2007 National Academy for Software Development - All rights reserved. Unauthorized copying or re-distribution is strictly prohibited.*

10 Create Database and Table in WAMP or XAMPP
* 07/16/96 Create Database and Table in WAMP or XAMPP (c) 2007 National Academy for Software Development - All rights reserved. Unauthorized copying or re-distribution is strictly prohibited.*

11 Create a Database Start Apache and MySQL services on XAMPP.
* 07/16/96 Start Apache and MySQL services on XAMPP. Press Admin as pointed in image to go to phpMyAdmin. (c) 2007 National Academy for Software Development - All rights reserved. Unauthorized copying or re-distribution is strictly prohibited.*

12 Create a Database * 07/16/96 (c) 2007 National Academy for Software Development - All rights reserved. Unauthorized copying or re-distribution is strictly prohibited.*

13 Create a Database * 07/16/96 Enter Database name ‘testdb’ and press create button. (c) 2007 National Academy for Software Development - All rights reserved. Unauthorized copying or re-distribution is strictly prohibited.*

14 Create a Table * 07/16/96 Enter table name ‘tbl_registration’ , number of fields ‘6’ and press GO button to create table . (c) 2007 National Academy for Software Development - All rights reserved. Unauthorized copying or re-distribution is strictly prohibited.*

15 Create a Table * 07/16/96 Enter following fields and their types. Enter length of each field except for fld_date. Select CURRENT_TIMESTAMP value for fld_date in Default column. (c) 2007 National Academy for Software Development - All rights reserved. Unauthorized copying or re-distribution is strictly prohibited.*

16 Create a Table * 07/16/96 Check the checkbox of A_I that is auto-increament for fld_reg_id press SAVE button. (c) 2007 National Academy for Software Development - All rights reserved. Unauthorized copying or re-distribution is strictly prohibited.*

17 Create a Table Here you can see the table you have created. * 07/16/96
(c) 2007 National Academy for Software Development - All rights reserved. Unauthorized copying or re-distribution is strictly prohibited.*

18 PHP Connect to MySQL * 07/16/96
(c) 2007 National Academy for Software Development - All rights reserved. Unauthorized copying or re-distribution is strictly prohibited.*

19 Why to establish a connection?
* 07/16/96 Why to establish a connection? You should establish a connection to the MySQL database. This is an extremely important step because if your script cannot connect to its database, your queries to the database will fail. (c) 2007 National Academy for Software Development - All rights reserved. Unauthorized copying or re-distribution is strictly prohibited.*

20 How to establish a connection?
* 07/16/96 Create a new php file in Dreamweaver and save it as “connection.php”. Add following code in connection.php file. (c) 2007 National Academy for Software Development - All rights reserved. Unauthorized copying or re-distribution is strictly prohibited.*

21 Check Connection * 07/16/96 Execute connection.php page in browser and check if it displays success message or not. (c) 2007 National Academy for Software Development - All rights reserved. Unauthorized copying or re-distribution is strictly prohibited.*

22 * 07/16/96 PHP Login (c) 2007 National Academy for Software Development - All rights reserved. Unauthorized copying or re-distribution is strictly prohibited.*

23 HTML Login Form Create a new html page. Save it as login.html.
* 07/16/96 Create a new html page. Save it as login.html. Create login form in login.html as follow. (c) 2007 National Academy for Software Development - All rights reserved. Unauthorized copying or re-distribution is strictly prohibited.*

24 HTML Login Form * 07/16/96 Open the code view of login form and change followings: Browser Results: (c) 2007 National Academy for Software Development - All rights reserved. Unauthorized copying or re-distribution is strictly prohibited.*

25 PHP Login And Session (Start Session)
* 07/16/96 Create a new php page, save it as login.php , add following: (c) 2007 National Academy for Software Development - All rights reserved. Unauthorized copying or re-distribution is strictly prohibited.*

26 Welcome Page (Get Session Values)
* 07/16/96 Create a new php page and save it as welcome.php. Add following Code: (c) 2007 National Academy for Software Development - All rights reserved. Unauthorized copying or re-distribution is strictly prohibited.*

27 PHP Session Destroy * 07/16/96 Create a new php page and save it as logout.php. Add following Code: (c) 2007 National Academy for Software Development - All rights reserved. Unauthorized copying or re-distribution is strictly prohibited.*

28 PHP LOGIN * 07/16/96 MySQL records: Enter and Password and press SIGN IN Button. (c) 2007 National Academy for Software Development - All rights reserved. Unauthorized copying or re-distribution is strictly prohibited.*

29 If Login Is Successful If Login Is Not Successful Sign Out
* 07/16/96 If Login Is Not Successful Sign Out Click on Sign Out link welcome page will be redirected to login form page. (c) 2007 National Academy for Software Development - All rights reserved. Unauthorized copying or re-distribution is strictly prohibited.*


Download ppt "Web Design and Development"

Similar presentations


Ads by Google