This article mainly introduces the case of PHP bookmark system. Interested friends can refer to it. I hope it will be helpful to everyone.
1. Requirements analysis
First, each user needs to be identified. There should be a verification mechanism.
Secondly, you need to save a single user's bookmarks. Users should be able to add and delete bookmarks.
Again, it is necessary to recommend sites to users that may be of interest to them based on what is known about them.
2. Solution2.1 System flow chart
##2.2 File list in PHPbookmark3. Implement database
create database bookmarks; use bookmarks; create table user ( username varchar(16) primary key, passwd char(40) not null, email varchar(100) not null ); create table bookmark ( username varchar(16) not null, bm_URL varchar(255) not null, index (username), index (bm_URL) ); grant select, insert, update, delete on bookmarks.* to bm_user@localhost identified by 'password';
4. Implement basic website4.1 login.php
5. Implement user authentication5.1 register_form.php
16)) { throw new exception('Your password must be between 6 and 16 characters Please go back and try again.'); } //尝试注册 register($username,$email,$passwd); //注册会话变量 $_SESSION['valid_user'] = $username; //提供成员页面链接 do_html_header('Registration successful'); //HTML标题 echo 'Your registration was successful.Go to the members page to start setting up your bookmarks!'; //输出URL do_html_URL('member.php','Go to members page'); //HTML页脚 do_html_footer(); //HTML页脚 } catch(exception $e) { do_html_header('Problem:'); echo $e->getMessage(); do_html_footer(); exit; } ?>
'; do_html_URL('login.php','Login'); } else //不成功 { echo 'Could not log you out.
'; } } else { echo 'You were not logged in, and so have not been logged ot.
'; do_html_URL('login.php','Login'); } do_html_footer(); ?>
16) || (strlen($new_passwd) < 6)) { throw new exception('New password must be between 6 and 16 characters. Try again.'); } //尝试修改 change_password($_SESSION['valid_user'],$old_passwd,$new_passwd); echo 'Password changed.'; } catch(exception $e) { echo $e ->getMessage(); } display_user_menu(); do_html_footer(); ?>
'; } catch(exception $e) { echo 'Your password could not be reset - please try again later.'; } do_html_URL('login.php','Login'); do_html_footer(); ?>
6. Implement bookmark storage and retrieval6.1 add_bms.php
getMessage(); } display_user_menu(); do_html_footer(); ?>
You have not chosen any bookmarks to delete.
Please try again.'; display_user_menu(); do_html_footer(); exit; } else { if(count($del_me) > 0) { foreach($del_me as $url) { if(delete_bm($valid_user,$url)) { echo 'Deleted '. htmlspecialchars($url) .'.
'; } else { echo 'Could not delete '. htmlspecialchars($url) .'.
'; } } } else { echo 'No bookmarks selected for deletion'; } } if($url_array = get_user_urls($valid_user)) { display_user_urls($url_array); } display_user_menu(); do_html_footer(); ?>
getMessage(); } display_user_menu(); do_html_footer(); ?>
Summary: That’s it The entire content of the article is hoped to be helpful to everyone's study.
Related recommendations:
Examples of access methods for class attributes and class static variables in PHP
php cookie working principle and detailed explanation of examples
PHP uses socket to simulate POST method
The above is the detailed content of PHP bookmark system case. For more information, please follow other related articles on the PHP Chinese website!