1. Trang chủ
  2. » Khoa Học Tự Nhiên

PHP fast and easy web develo

342 67 0

Đang tải... (xem toàn văn)

Tài liệu hạn chế xem trước, để xem đầy đủ mời bạn chọn Tải xuống

THÔNG TIN TÀI LIỆU

Thông tin cơ bản

Định dạng
Số trang 342
Dung lượng 1,97 MB

Nội dung

This document is created with a trial version of CHM2PDF Pilot http://www.colorpilot.com PHP Fast & Easy Web Development, 2nd Edition by Julie C Meloni Premier Press © 2002 (481 pages) Getting Web developers up to speed with PHP Table of Contents Back Cover Table of Contents PHP Fast & Easy Web Development, 2nd Edition Introduction Part I - Getting Started Chapter Chapter Chapter - Installing and Configuring MySQL - Installing Apache - Installing PHP Part II - The Absolute Basics of Coding in PHP Chapter Chapter Chapter - Mixing PHP and HTML - Introducing Variables and Operators - Using Variables Part III - Start with Simple Stuff Chapter Chapter Chapter Chapter 10 - Displaying Dynamic Content Sending E-Mail Using Your File System Uploading Files to Your Web Site Part IV - Getting to Know Your Database Chapter 11 Chapter 12 Chapter 13 Chapter 14 - Establishing a Connection Creating a Database Table Inserting Data into a Table Selecting and Displaying Data Part V - User Authentication and Tracking Chapter 15 Chapter 16 Chapter 17 - Database-Driven User Authentication - Using Cookies - Session Basics Part VI - Creating Your Own Contact Management System Chapter 18 Chapter 19 Chapter 20 Chapter 21 Chapter 22 - Planning Your System Adding Contacts Modifying Contacts Deleting Contacts Working with Contacts Part VII - Additional Administration Scripts Chapter 23 Chapter 24 - Managing a Simple Mailing List - Creating Custom Logs and Reports Part VIII - Appendixes Appendix A Appendix B Appendix C Appendix D Appendix E Appendix F Index List of Tables - Additional Configuration Options Basic PHP Language Reference Writing Your Own Functions Basic MySQL Reference Database Normalization Getting Help ISBN:193184187x This document is created with a trial version of CHM2PDF Pilot http://www.colorpilot.com This document is created with a trial version of CHM2PDF Pilot http://www.colorpilot.com PHP Fast & Easy Web Development, 2nd Edition by Julie C Meloni Premier Press © 2002 (481 pages) Getting Web developers up to speed with PHP Table of Contents Back Cover Table of Contents PHP Fast & Easy Web Development, 2nd Edition Introduction Part I - Getting Started Chapter Chapter Chapter - Installing and Configuring MySQL - Installing Apache - Installing PHP Part II - The Absolute Basics of Coding in PHP Chapter Chapter Chapter - Mixing PHP and HTML - Introducing Variables and Operators - Using Variables Part III - Start with Simple Stuff Chapter Chapter Chapter Chapter 10 - Displaying Dynamic Content Sending E-Mail Using Your File System Uploading Files to Your Web Site Part IV - Getting to Know Your Database Chapter 11 Chapter 12 Chapter 13 Chapter 14 - Establishing a Connection Creating a Database Table Inserting Data into a Table Selecting and Displaying Data Part V - User Authentication and Tracking Chapter 15 Chapter 16 Chapter 17 - Database-Driven User Authentication - Using Cookies - Session Basics Part VI - Creating Your Own Contact Management System Chapter 18 Chapter 19 Chapter 20 Chapter 21 Chapter 22 - Planning Your System Adding Contacts Modifying Contacts Deleting Contacts Working with Contacts Part VII - Additional Administration Scripts Chapter 23 Chapter 24 - Managing a Simple Mailing List - Creating Custom Logs and Reports Part VIII - Appendixes Appendix A Appendix B Appendix C Appendix D Appendix E Appendix F Index List of Tables - Additional Configuration Options Basic PHP Language Reference Writing Your Own Functions Basic MySQL Reference Database Normalization Getting Help ISBN:193184187x This document is created with a trial version of CHM2PDF Pilot http://www.colorpilot.com This document is created with a trial version of CHM2PDF Pilot http://www.colorpilot.com PHP Fast & Easy Web Development, 2nd Edition by Julie C Meloni Premier Press © 2002 (481 pages) Getting Web developers up to speed with PHP Table of Contents ISBN:193184187x Back Cover Back Cover Don’t spend your time wading through manuals to learn PHP Spend it doing what you best— creating Web pages! Get the skills you need to install PHP, create a database, and upload files to the Web Combining easy-to-understand instructions with visual examples, PHP Fast & Easy Web Development, 2nd Edition offers a unique, hands-on approach to PHP that you won’t find anywhere else Less time, less effort, more results! Screen by screen, use this comprehensive PHP guide to: Master the basics of coding in PHP Create a Contact Management System Create custom logs and reports Authenticate and track users Display dynamic content About the Author Julie Meloni is the technical director for i2i Interactive, a multimedia company located in Campbell, CA She’s been developing Web-based applications since the Web first saw the light of day and remembers the excitement surrounding the first GUI Web browser She is the author of several books and articles on Web-based programming languages and database topics This document is created with a trial version of CHM2PDF Pilot http://www.colorpilot.com PHP Fast & Easy Web Development, 2nd Edition by Julie C Meloni Premier Press © 2002 (481 pages) Getting Web developers up to speed with PHP Table of Contents Back Cover Table of Contents PHP Fast & Easy Web Development, 2nd Edition Introduction Part I - Getting Started Chapter Chapter Chapter - Installing and Configuring MySQL - Installing Apache - Installing PHP Part II - The Absolute Basics of Coding in PHP Chapter Chapter Chapter - Mixing PHP and HTML - Introducing Variables and Operators - Using Variables Part III - Start with Simple Stuff Chapter Chapter Chapter Chapter 10 - Displaying Dynamic Content Sending E-Mail Using Your File System Uploading Files to Your Web Site Part IV - Getting to Know Your Database Chapter 11 Chapter 12 Chapter 13 Chapter 14 - Establishing a Connection Creating a Database Table Inserting Data into a Table Selecting and Displaying Data Part V - User Authentication and Tracking Chapter 15 Chapter 16 Chapter 17 - Database-Driven User Authentication - Using Cookies - Session Basics Part VI - Creating Your Own Contact Management System Chapter 18 Chapter 19 Chapter 20 Chapter 21 Chapter 22 - Planning Your System Adding Contacts Modifying Contacts Deleting Contacts Working with Contacts Part VII - Additional Administration Scripts Chapter 23 Chapter 24 - Managing a Simple Mailing List - Creating Custom Logs and Reports Part VIII - Appendixes Appendix A Appendix B Appendix C Appendix D Appendix E Appendix F Index List of Tables - Additional Configuration Options Basic PHP Language Reference Writing Your Own Functions Basic MySQL Reference Database Normalization Getting Help ISBN:193184187x This document is created with a trial version of CHM2PDF Pilot http://www.colorpilot.com This document is created with a trial version of CHM2PDF Pilot http://www.colorpilot.com PHP Fast & Easy Web Development, 2nd Edition Julie C Meloni Copyright © 2002 by Premier Press All rights reserved No part of this book may be reproduced or transmitted in any form or by any means, electronic or mechanical, including photocopying, recording, or by any information storage or retrieval system without written permission from Premier Press, except for the inclusion of brief quotations in a review The Premier Press logo, top edge printing, and related trade dress are trademarks of Premier Press, Inc and may not be used without written permission All other trademarks are the property of their respective owners Publisher: Stacy L Hiquet Marketing Manager: Heather Buzzingham Managing Editor: Sandy Doell Acquisitions Editor: Todd Jensen Project Editor: Kim V Benbow Editorial Assistant: Margaret Bauer Marketing Coordinator: Kelly Poffenbarger Technical Reviewer: Greg Perry Copy Editor: Kim V Benbow Interior Layout: Scribe Tribe Cover Design: Mike Tanamachi Indexer: Johnna VanHoose Dinse PHP is copyrighted by The PHP Group, and is released under the PHP License More information on the licensing terms is available in the license file within the PHP distribution or by visiting http://www.php.net/license/ Microsoft, Windows, and Internet Explorer are either registered trademarks or trademarks of Microsoft Corporation in the United States and/or other countries Netscape is a registered trademark of Netscape Communications Corporation in the U.S and other countries All other trademarks are the property of their respective owners Important: Premier Press cannot provide software support Please contact the appropriate software manufacturer's technical support line or Web site for assistance Premier Press and the author have attempted throughout this book to distinguish proprietary trademarks from descriptive terms by following the capitalization style used by the manufacturer Information contained in this book has been obtained by Premier Press from sources believed to be reliable However, because of the possibility of human or mechanical error by our sources, Premier Press, or others, the Publisher does not guarantee the accuracy, adequacy, or completeness of any information and is not responsible for any errors or omissions or the results obtained from use of such information Readers should be particularly aware of the fact that the Internet is an ever-changing entity Some facts may have changed since this book went to press ISBN: 1-931841-87-X Library of Congress Catalog Card Number: 2002104489 Printed in the United States of America 02 03 04 05 RI 10 Acknowledgments Thanks as always to the PHP Group, Zend Technologies, the Apache Software Foundation, and MySQL AB for creating and maintaining such wonderful and accessible products for all users Thanks to every single PHP user and developer because without you, I wouldn't have anything to write about Great thanks to the all the editors who worked with me on both editions of this book! Enormous thanks to everyone at i2i Interactive, for their never-ending support and encouragement About the Author JULIE MELONI is the technical director for i2i Interactive, a multimedia company located in Campbell, CA (that's just down This document is created with a trial version of CHM2PDF Pilot http://www.colorpilot.com JULIE MELONI is the technical director for i2i Interactive, a multimedia company located in Campbell, CA (that's just down the street from San Jose) She's been developing Web-based applications since the Web first saw the light of day and remembers the excitement surrounding the first GUI Web browser She is the author of several books and articles on Webbased programming languages and database topics, and you can find translations of her work in several languages, including Chinese, Italian, Portuguese, Polish, and even Serbian This document is created with a trial version of CHM2PDF Pilot http://www.colorpilot.com Using Cookie Variables There's an element to using cookies that most people forget about until they spend a few hours trying to debug something that isn't even wrong (I've done this) When a Web browser accepts a cookie, you can't extract its value until the next HTTP request is made In other words, if you set a cookie called name with a value of Julie on page 1, you can't extract that value until the user reaches page (or page or page 28—just some other page that isn't the page on which the cookie is initially set) Using Cookies with Authentication In the authentication script in the previous chapter, you had a login form and a results page However, the authentication was valid only for the results page because it dynamically displayed the secret content (in this case, a "Congratulations!" message) If you want to require authentication for a series of static pages, you have to make some minor adjustments Open do_authuser.php in your text editor Scroll down to the if … else block that deals with the result of the authentication Add a block that sets a cookie: if ($num != 0) { $cookie_name = "auth"; $cookie_value = "ok"; $cookie_expire = "0"; $cookie_domain = "127.0.0.1"; setcookie($cookie_name, $cookie_value, $cookie_expire, "/" , $cookie_domain, 0); Note The setcookie() function will send a cookie called auth with a value of ok It will expire at the end of the browser session and will be valid for all directories on 127.0.0.1 Use your own domain name if appropriate Delete this line: $msg = "

Congratulations, you're authorized!

"; Add this string: $display_block = "

Secret Menu:

  • secret page A
  • secret page B
"; Note Don't worry; you'll create these pages soon enough Scroll until you see the following: Replace it with this: Save the file Your new code should look like this:

Ngày đăng: 25/03/2019, 15:47