7、原始碼

來源:互聯網
上載者:User
一個簡單的PHP線上書籤系統

1、需求分析

首先,需要識別每個使用者。應該有驗證機制。

其次,需要儲存單個使用者的書籤。使用者應該能夠添加和刪除書籤。

再次,需要根據對他們的瞭解,向使用者建議他們可能感興趣的網站。


2、解決方案

2.1 系統流程圖

2.2 PHPbookmark中的檔案清單

檔案名稱

描述

bookmarks.sql

建立PHPbookmark的資料庫SQL語句

login.php

包含系統登入表單的頁面

register_form.php

系統中使用者註冊表單

register_new.php

處理新註冊資訊的指令碼

forgot_form.php

使用者忘記密碼後需要填寫的表單

forgot_passwd.php

重新設定遺忘密碼的指令碼

member.php

使用者的首頁面,包含該使用者所有的當前書籤

add_bm_form.php

添加書籤的表單

add_bms.php

將書籤真正添加到資料庫中的指令碼

delete_bms.php

從使用者的書籤列表中刪除選定書籤的指令碼呢

recommend.php

基於使用者以前的操作,推薦使用者可能感興趣的書籤

change_passwd_form.php

使用者修改密碼時要填寫的表單

change_passwd.php

修改資料庫中使用者密碼的表單

logout.php

將使用者登出的指令碼

bookmark_fns.php

應用程式的包含檔案集合

data_valid_fns.php

確認使用者輸入資料有效函數

db_fns.php

串連資料庫的函數

user_auth_fns.php

使用者身分識別驗證的函數

url_fns.php

增加和刪除書籤的函數

output_fns.php

以HTML形式格式化輸出的函數

bookmark.gif

PHPbookmark的logo表徵圖



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, deleteon bookmarks.*to [email protected] identified by 'password';

4、實現基本的網站

4.1 login.php



4.2 bookmark_fns.php



5、實現使用者身分識別驗證

5.1 register_form.php



5.2 register_new.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;    }?>

5.3 member.php



5.4 logout.php

';            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();?>

5.5 change_passwd.php

 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();?>

5.6 forgot_paswd.php

';    }    catch(exception $e)    {        echo 'Your password could not be reset - please try again later.';    }    do_html_URL('login.php','Login');    do_html_footer();?>

6、實現書籤的儲存和檢索

6.1 add_bms.php

getMessage();    }    display_user_menu();    do_html_footer();?>

6.2 delete_bms.php

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();?>

6.3 recommend.php

getMessage();    }    display_user_menu();    do_html_footer();?>

7、原始碼

下載地址



著作權聲明:本文為博主原創文章,未經博主允許不得轉載。

  • 聯繫我們

    該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

    如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.