Home arrow PHP arrow Page 6 - Building an E-Commerce Site Part 2: Managing Users with Sessions

Step 2: Extracting the New Scripts - PHP

This is the second article in a three-part series dealing with using PHP 4 and MySQL to make a comprehensive e-commerce storefront solution. This article covers session management within the store, user privileges, and a few security concerns.

TABLE OF CONTENTS:
  1. Building an E-Commerce Site Part 2: Managing Users with Sessions
  2. Assumptions and Requirements
  3. Primer on Sessions
  4. User Management and Privileges
  5. Step 1: Creating the Users Table
  6. Step 2: Extracting the New Scripts
  7. Step 3: General Script Changes from Tutorial 1
  8. Step 5: User Scripts
  9. Step 6: A Note on Security
  10. Step 7: Putting It All Together
By: Ying Zhang
Rating: starstarstarstarstar / 33
May 16, 2000

print this article
SEARCH DEV SHED

TOOLS YOU CAN USE

advertisement

Okay, we've got our user table, let's make screens for the user to log in and log out. Download the mymarket2.tar.gz file and extract it into your web root directory. Note that this replaces the files from the first tutorial.

IMPORTANT NOTE: If you have made modifications to the files from the first tutorial, please make a backup copy and store it somewhere else. The files in mymarket2.tar.gz will overwrite any changes you made to the files from the first tutorial.

We do the same drill from the first tutorial. Download the mymarket2.tar.gz file and extract it into your web root directory. For example, if your web root is in

type


$ tar -zxf /tmp/mymarket2.tar.gz

Assuming that you've downloaded mymarket2.tar.gz into /tmp. Now, open up the file application.php and change the $CFG->wwwroot and $CFG->dirroot paths to match your server configuration.

Before we dive into the source code, let me explain how I've setup the directories and files. Once you go into the mymarket directory, you will see five directories, and four files. Everything in bold is new to this tutorial:


drwxrws--- 2 ying web 1024 Apr 20 02:05 images/ drwxrws--- 2 ying web 1024 May 4 09:18 lib/ drwxrws--- 3 ying web 1024 May 9 11:20 templates/ drwxrwsr-x 3 lanuser web 1024 May 9 11:20 users/ -rw-rw---- 1 ying web 2074 May 7 14:58 application.php -rw-rw-r-- 1 lanuser web 1488 May 7 12:21 index.php -rw-rw-r-- 1 lanuser web 2427 May 7 14:51 login.php -rw-rw-r-- 1 lanuser web 1040 May 9 11:19 logout.php

I won't go over the files and directories that were from the first tutorial (admin, images, lib, templates) except to say that the scripts inside them have changed a bit. Take a look at them and see if you can spot what's changed <grin>, just kidding, I will cover those as necessary :)

The users directory is where we keep the scripts relating to user functions. For now, it contains scripts to let the users signup for an account, change their password, change their settings, and retrieve forgotten passwords.

The index.php file is the MyMarket homepage. We didn't have one of these from part 1 of this guide because we were only interested in the administrative functions. We have it now only to show a dummy homepage (which we will add to in part 3 of this guide).

The login.php and logout.php files handle the process of logging in and logging out. We've briefly gone over what was involved in logging in and logging out, see these scripts for more details.



 
 
>>> More PHP Articles          >>> More By Ying Zhang
 

blog comments powered by Disqus
escort Bursa Bursa escort Antalya eskort
   

PHP ARTICLES

- Hackers Compromise PHP Sites to Launch Attac...
- Red Hat, Zend Form OpenShift PaaS Alliance
- PHP IDE News
- BCD, Zend Extend PHP Partnership
- PHP FAQ Highlight
- PHP Creator Didn't Set Out to Create a Langu...
- PHP Trends Revealed in Zend Study
- PHP: Best Methods for Running Scheduled Jobs
- PHP Array Functions: array_change_key_case
- PHP array_combine Function
- PHP array_chunk Function
- PHP Closures as View Helpers: Lazy-Loading F...
- Using PHP Closures as View Helpers
- PHP File and Operating System Program Execut...
- PHP: Effects of Wrapping Code in Class Const...

Developer Shed Affiliates

 


Dev Shed Tutorial Topics: