Admin - User Management
A user of the shop is actually the shop admin itself. Currently all user are granted the permission to do all administration task. In future version i'll modify this so one user can be assigned to specific task such as managing the products or managing the orders, etc. View User ListThis display just display all user on the shop
Add UserThe only information needed are the user name and password.
Here is the code for adding a user. Source code : admin/user/processUser.php function addUser()
{ $userName = $_POST['txtUserName']; $password = $_POST['txtPassword']; // check if the username is taken $sql = "SELECT user_name FROM tbl_user WHERE user_name = '$userName'"; $result =& dbQuery($sql); if (dbNumRows($result) == 1) { header('Location: index.php?view=add&error=' . urlencode('Username already taken. Choose another one')); } else { $sql = "INSERT INTO tbl_user (user_name, user_password, user_regdate) VALUES ('$userName', PASSWORD('$password'), NOW())"; dbQuery($sql); header('Location: index.php'); } } Before adding the new user info we need to check if the username is taken or not. We just query the database looking for that username. If a row is found that mean the username is already used and we set a redirect to go back to the 'add user' page and send an error message. Since the error message is put in the query string we need to use urlencode(). This function is commonly used when passing a string to a url. Using the above example the url will look like this : index.php?view=add&error=Username+already+taken.+Choose+another+one If the username is still available we just insert the new user info to database. You see that in the insert query we use PASSWORD() function. This is a MySQL function that will encrypt the given password.
Modify User PasswordFor simplicity the user name cannot be changed. Only the password can be changed. The function used for modifying the password simply perform an UPDATE query to update the password
Delete UserThe deleteUser() function just remove a user from database. No extra steps needed. |
|
|
Admin - Online Shop Configuration | PHP MySQL Shopping Cart Tutorial : Admin - User management | Online Shop - Main Page |
|
At long last i'm finally able to update this site. Now the shopping cart can handle payment through paypal. As always you have any critiques, questions, comments or problems about this tutorial please tell me. Click here to send your feedback. And if you like this tutorial please link to this site. It will really help a lot :-) |
PHP MySQL Shopping Cart Tutorial
Copyright © 2005 - 2009 www.phpwebcommerce.com