• 欢迎访问搞代码网站,推荐使用最新版火狐浏览器和Chrome浏览器访问本网站!
  • 如果您觉得本站非常有看点,那么赶紧使用Ctrl+D 收藏搞代码吧

PHP书签系统案例

php 搞代码 4年前 (2022-01-22) 41次浏览 已收录 0个评论

本篇文章主要介绍PHP书签系统案例,感兴趣的朋友参考下,希望对大家有所帮助。

1、需求分析

首先,需要识别每个用户。应该有验证机制。
其次,需要保存单个用户的书签。用户应该能够添加和删除书签。
再次,需要根据对他们的了解,向用户建议他们可能感兴趣的站点。

2、解决方案2.1 系统流程图

2.2 PHPbookmark中的文件列表

3、实现数据库

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、实现基本的网站4.1 login.php

<?php  /**  * 包含系统登录表单的页面  */   //require_once语句和require语句完全相同,唯一区别是PHP会检查该文件是否已经被包含过,如果是则不会再次包含。   require_once('bookmark_fns.php');  //应用程序的包含文件集合      do_html_header(''); //HTML标题      display_site_info();//HTML站点信息   display_login_form();//HTML登录信息      do_html_footer();  //HTML页脚 ?>

4.2 bookmark_fns.php

<?php  /**  * 应用程序的包含文件集合  */   //require_once语句和require语句完全相同,唯一区别是PHP会检查该文件是否已经被包含过,如果是则不会再次包含。   require_once('data_valid_fns.php'); //确认用户输入数据有效的函数   require_once('db_fns.php'); // 连接数据库的函数   require_once('user_auth_fns.php'); //用户身份验证的函数   require_once('output_fns.php'); //以HTML形式格式化输出的函数   require_once('url_fns.php');  //增加和删除书签的函数 ?>

5、实现用户身份验证5.1 register_form.php

<?php  /**  * 系统中用户注册表单  */   //require_once语句和require语句完全相同,唯一区别是PHP会检查该文件是否已经被包含过,如果是则不会再次包含。   require_once('bookmark_fns.php');   do_html_header('User Registration');  //HTML标题      display_registeration_form();  //输出注册表单      do_html_footer();  //HTML页脚 ?>

5.2 register_new.php

<?php  /**  * 处理新注册信息的脚本  */   //require_once语句和require语句完全相同,唯一区别是PHP会检查该文件是否已经被包含过,如果是则不会再次包含。   require_once('bookmark_fns.php');      //创建变量   $email = $_POST['email'];   $username = $_POST['username'];   $passwd = $_POST['passwd'];   $passwd2 = $_POST['passwd2'];    //开启会话   session_start();      try   {     //检查表单是否填写满     if(!filled_out($_POST))     {       throw new exception('You have not filled the form out correctly - please go back and try again.');     }          //检查邮件地址是否有效     if(!valid_email($email))     {       throw new exception('That is not a vald email address. Please go back try again.');     }          //检查两次输入密码是否相同     if($passwd != $passwd2)     {       throw new exception('The passwords you entered do not match - please go back try again.');     }          //检查密码长度是否合格     if((strlen($passwd) < 6) || (strlen($passwd) > 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<b>%本文@来源gao@!dai!ma.com搞$$代^@码!网</b><strong>搞代gaodaima码</strong>.php','Go to members page'); //HTML页脚     do_html_footer();  //HTML页脚   }   catch(exception $e)   {     do_html_header('Problem:');     echo $e->getMessage();     do_html_footer();     exit;   } ?>

搞代码网(gaodaima.com)提供的所有资源部分来自互联网,如果有侵犯您的版权或其他权益,请说明详细缘由并提供版权或权益证明然后发送到邮箱[email protected],我们会在看到邮件的第一时间内为您处理,或直接联系QQ:872152909。本网站采用BY-NC-SA协议进行授权
转载请注明原文链接:PHP书签系统案例

喜欢 (0)
[搞代码]
分享 (0)
发表我的评论
取消评论

表情 贴图 加粗 删除线 居中 斜体 签到

Hi,您需要填写昵称和邮箱!

  • 昵称 (必填)
  • 邮箱 (必填)
  • 网址