Home>Article>Backend Development> Code 2 about implementing shopping cart in php
This article mainly introduces all the codes for implementing the shopping cart function in PHP, and proposes demand analysis, solutions, and database creation to help you easily implement the shopping cart function. Interested friends can refer to it
Continue learning from the previous article:"About the code for implementing shopping cart in PHP 1"
7. Implement a management interface
Login interface
is implemented by the following code:
7.1 admin.php
You could not be logged in.
You must be logged in to view this page."; do_html_URL('login.php','Login'); do_html_footer(); exit; } } do_html_header("Administration"); if(check_admin_user()) { display_admin_menu(); } else { echo "You are not authorized to enter the administration area.
"; do_html_URL('login.php','Login'); } do_html_footer(); ?>
7.2 The function login() in the user_auth_fns.php file
function login($username,$password) //登录 { $conn = db_connect(); //连接数据库 if(!$conn) return 0; //检查用户名唯一性 $query = "select * from admin where username='". $username ."' and password = sha1('". $password ."')"; $result = $conn ->query($query); if(!$result) return 0; if($result ->num_rows > 0) return 1; else return 0; }
7.3 The function check_admin_user() in the user_auth_fns.php file
function check_admin_user() //检查是否是管理员 { if(isset($_SESSION['admin_user'])) return true; else return false; }
Management main interface
is implemented by the following code:
7.4 Function display_admin_menu() in the output_fns.php file
function display_admin_menu() //输出管理员菜单 { ?>
Go to main site
Add a new category
Add a new book
Change admin password
"; }
Directory addition
Directory added successfully
You can see more Novel directories on the directory page
Achieved by the following code :
7.5 insert_category_form.php
You are not authorized to enter the administation area."; } do_html_footer(); ?>
7.6 insert_category.php
##
Category \"". $catname ."//m.sbmmt.com/m/faq/\" was added to the database."; } else { echo "Category \"". $catname ."//m.sbmmt.com/m/faq/\" could not be added to the database.
"; } } else { echo "You have not filled out the form. Please try again.
"; } do_html_URL("admin.php","Back to administration menu"); } else { echo "You are not authorised to view this page.
"; } do_html_footer(); ?>
Administrator directory interface
is implemented by the following code:
Could not retrieve category details."; } do_html_URL("admin.php","Back to administration menu"); } else { echo "You are not authorized to enter the administration area.
"; } do_html_footer(); ?>
7.8 edit_category.php
Category was updated."; } else { echo "Category could not be updated.
"; } } else { echo "you have not filled out the form. Please try again.
"; } do_html_URL("admin.php","Back to administration menu"); } else { echo "You are not authorised to view this page.
"; } do_html_footer(); ?>
7.9 admin_fns.php
ISBN: | |
Book Title: | |
Book Author: | |
Category: | |
Price: | |
Description: | |
align="center"> ";?> |
Old password: | |
New password: | |
Repeat new password: | |
7.10 Catalog deletion operations, book addition, update, and deletion operations are basically similar to the above operations. They will not be demonstrated here. You can download the code to view
8. Extension
This project was created A fairly simple PHP shopping cart system. We can also make many improvements and enhancements to it:# In a real online store, some order recording and implementation system may have to be established - in this system , the user cannot see the orders that have been booked.
Customers want to be able to check on the status of their order without having to contact us. Users should have a means of authentication that enables them to view their previous orders and also allow them to closely tie actions to their personal circumstances. It is also more convenient for us to collect some user habit information.
Pictures of the book can be transferred to the site's images directory via a service such as FTP and given an appropriate name. You can upload files to the image insertion page to make this operation easier.
You can add user login, personalized settings and book recommendations, online reviews, membership systems, inventory level checks, etc. There are so many features that can be added.
Related recommendations:
About the code for implementing the shopping cart in PHP 1##
The above is the detailed content of Code 2 about implementing shopping cart in php. For more information, please follow other related articles on the PHP Chinese website!