PHP用户验证和标签推荐的简单使用(4)

<?php require_once('bookmark_fns.php'); do_html_header('User Registration'); display_registration_form(); do_html_footer(); ?> register_new.php <?php require_once('bookmark_fns.php'); // vars $email = $_POST['email']; $username = $_POST['username']; $passwd = $_POST['passwd']; $passwd2 = $_POST['passwd2']; // start session session_start(); // valid data try { if (!filled_out($_POST)) { throw new Exception("You have not filled the form out correctly - please go back and try again.", 1); } if (!valid_email($email)) { throw new Exception("That is not a valid email address - please go back and try again.", 1); } if ($passwd != $passwd2) { throw new Exception("The passwords you entered do not match - please go back and try again.", 1); } 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.", 1); } register($username, $passwd, $email); $_SESSION['valid_user'] = $username; do_html_header('Rigistration successful'); do_html_url('https://www.jb51.net/member.php', 'Go to members page'); do_html_footer(); } catch (Exception $e) { do_html_header('Problem: '); echo $e -> getMessage(); do_html_footer(); exit(); } ?>

forgot_form.php

<?php require_once('bookmark_fns.php'); do_html_header('Reset password'); display_forgot_form(); do_html_footer(); ?> forgot_passwd.php <?php require_once('bookmark_fns.php'); do_html_header('Resetting password'); $username = $_POST['username']; try { // get random password $password = reset_password($username); notify_password($username, $password); echo "Your new password has been emailed to you.<br />"; }catch(Exception $e){ echo "Your password could not be reset - please try again later."; } do_html_url('login.php', 'Login'); do_html_footer(); ?> change_passwd_form.php <?php require_once('bookmark_fns.php'); session_start(); do_html_header('Change password'); check_valid_user(); display_password_form(); display_user_menu(); do_html_footer(); ?> change_passed.php <?php require_once('bookmark_fns.php'); session_start(); do_html_header('Changing password'); $old_passwd = $_POST['old_passwd']; $new_passwd = $_POST['new_passwd']; $new_passwd2 = $_POST['new_passwd2']; try { check_valid_user(); if (!filled_out($_POST)) { throw new Exception("You have not filled the form out correctly - please go back and try again.", 1); } if ($new_passwd != $new_passwd2) { throw new Exception("The passwords you entered do not match - please go back and try again.", 1); } if ((strlen($new_passwd) < 6) || (strlen($new_passwd) > 16)) { throw new Exception("Your password must be between 6 and 16 characters - please go back and try again.", 1); } change_password($_SESSION['valid_user'], $old_passwd, $new_passwd2); echo 'Password changed.'; }catch(Exception $e) { echo $e -> getMessage(); } display_user_menu(); do_html_footer(); ?> add_bm_form.php <?php // include function files for this application require_once('bookmark_fns.php'); session_start(); // start output html do_html_header('Add Bookmarks'); check_valid_user(); display_add_bm_form(); display_user_menu(); do_html_footer(); ?>

add_bms.php

内容版权声明:除非注明,否则皆为本站原创文章。

转载注明出处:https://www.heiqu.com/e491488caa6d95c5c9352240082a9d5a.html