You are previewing Web Developer’s Cookbook: More Than 300 Ready-Made PHP, JavaScript, and CSS Recipes.
O'Reilly logo
Web Developer’s Cookbook: More Than 300 Ready-Made PHP, JavaScript, and CSS Recipes

Book Description

300+ Ready-to-Use PHP, JavaScript, and CSS Solutions

Web Developer's Cookbook contains more than 300 PHP, JavaScript, and CSS recipes you can use right away to create interactive Web content. All of the solutions are fully documented and their functionality clearly explained, along with customization tips. The recipes include HTML examples and screen shots showing exactly how to apply them in real-world situations. Methods for using HTML5 to make Web pages even more interactive and dynamic are also provided. Shorten development time and sharpen your programming skills with help from this practical guide.

Filled with tested recipes for:

PHP

Text processing * Image handling * Content management * Forms and user input * Internet * Chat and messaging * MySQL, sessions, and cookies * APIs, RSS, and XML * Incorporating JavaScript

JavaScript

Core functionality * Location and dimensions * Visibility * Movement and animation * Chaining and interaction * Menus and navigation * Text effects * Audio and visual effects * Cookies, Ajax, and security * Forms and validation * Solutions to common problems

CSS

Manipulating objects * Text and typography * Menus and navigation * Page layout * Visual effects * Dynamic objects * Dynamic text and typography * Incorporating JavaScript * Superclasses

Table of Contents

  1. Cover 
  2. Title
  3. Copyright
  4. Dedication
  5. About the Author
  6. Contents 
  7. Acknowledgments
  8. Introduction
  9. Part I: Introduction
    1. 1. Getting Started
      1. Downloading and Installing Web Browsers
      2. Choosing a Program Editor
      3. Installing a PHP Server
      4. Older Versions of Microsoft Internet Explorer
      5. The Companion Web Site
    2. 2. Using the Recipes
      1. Inserting the PHP Recipes
      2. Inserting the JavaScript Recipes
      3. Inserting the CSS Recipes
      4. A Quick Refresher on the DOM
      5. Summary
  10. Part II: PHP Recipes
    1. 3. Text Processing
      1. Recipe 1: WrapText()
      2. Recipe 2: CapsControl()
      3. Recipe 3: FriendlyText()
      4. Recipe 4: StripWhitespace()
      5. Recipe 5: WordSelector()
      6. Recipe 6: CountTail()
      7. Recipe 7: TextTruncate()
      8. Recipe 8: SpellCheck()
      9. Recipe 9: RemoveAccents()
      10. Recipe 10: ShortenText()
    2. 4. Image Handling
      1. Recipe 11: UploadFile()
      2. Recipe 12: ImageResize()
      3. Recipe 13: MakeThumbnail()
      4. Recipe 14: ImageAlter()
      5. Recipe 15: ImageCrop()
      6. Recipe 16: ImageEnlarge()
      7. Recipe 17: ImageDisplay()
      8. Recipe 18: ImageConvert()
      9. Recipe 19: GifText()
      10. Recipe 20: ImageWatermark()
    3. 5. Content Management
      1. Recipe 21: RelToAbsURL()
      2. Recipe 22: GetLinksFromURL()
      3. Recipe 23: CheckLinks()
      4. Recipe 24: DirectoryList()
      5. Recipe 25: QueryHighlight()
      6. Recipe 26: RollingCopyright()
      7. Recipe 27: EmbedYouTubeVideo()
      8. Recipe 28: CreateList()
      9. Recipe 29: HitCounter()
      10. Recipe 30: RefererLog()
    4. 6. Forms and User Input
      1. Recipe 31: EvaluateExpression()
      2. Recipe 32: ValidateCC()
      3. Recipe 33: CreateCaptcha()
      4. Recipe 34: CheckCaptcha()
      5. Recipe 35: ValidateText()
      6. Recipe 36: ValidateEmail()
      7. Recipe 37: SpamCatch()
      8. Recipe 38: SendEmail()
      9. Recipe 39: BBCode()
      10. Recipe 40: PoundCode()
    5. 7. The Internet
      1. Recipe 41: LookupLinks()
      2. Recipe 42: GetTitleFromURL()
      3. Recipe 43: AutoBackLinks()
      4. Recipe 44: CreateShortURL()
      5. Recipe 45: UseShortURL()
      6. Recipe 46: SimpleWebProxy()
      7. Recipe 47: PageUpdated()
      8. Recipe 48: HTMLToRSS()
      9. Recipe 49: RSSToHTML()
      10. Recipe 50: HTMLToMobile()
    6. 8. Chat and Messaging
      1. Recipe 51: UsersOnline()
      2. Recipe 52: PostToGuestBook()
      3. Recipe 53: GetGuestBook()
      4. Recipe 54: PostToChat()
      5. Recipe 55: ViewChat()
      6. Recipe 56: SendTweet()
      7. Recipe 57: SendDirectTweet()
      8. Recipe 58: GetTweets()
      9. Recipe 59: ReplaceSmileys()
      10. Recipe 60: ReplaceSMSTalk()
    7. 9. MySQL, Sessions, and Cookies
      1. Recipe 61: AddUserToDB()
      2. Recipe 62: GetUserFromDB()
      3. Recipe 63: VerifyUserInDB()
      4. Recipe 64: SanitizeString() and MySQLSanitizeString()
      5. Recipe 65: CreateSession()
      6. Recipe 66: OpenSession()
      7. Recipe 67: CloseSession()
      8. Recipe 68: SecureSession()
      9. Recipe 69: ManageCookie()
      10. Recipe 70: BlockUserByCookie()
    8. 10. APIs, RSS, and XML
      1. Recipe 71: CreateGoogleChart()
      2. Recipe 72: CurlGetContents()
      3. Recipe 73: FetchWikiPage()
      4. Recipe 74: FetchFlickrStream()
      5. Recipe 75: GetYahooAnswers()
      6. Recipe 76: SearchYahoo()
      7. Recipe 77: GetYahooStockNews()
      8. Recipe 78: GetYahooNews()
      9. Recipe 79: SearchGoogleBooks()
      10. Recipe 80: ConvertCurrency()
    9. 11. Incorporating JavaScript
      1. Recipe 81: CreateAjaxObject()
      2. Recipe 82: GetAjaxRequest()
      3. Recipe 83: PostAjaxRequest()
      4. Recipe 84: ProtectEmail()
      5. Recipe 85: ToggleText()
      6. Recipe 86: StatusMessage()
      7. Recipe 87: SlideShow()
      8. Recipe 88: InputPrompt()
      9. Recipe 89: WordsFromRoot()
      10. Recipe 90: PredictWord()
    10. 12. Diverse Solutions
      1. Recipe 91: GetCountryFromIP()
      2. Recipe 92: BypassCaptcha()
      3. Recipe 93: GetBookFromISBN()
      4. Recipe 94: GetAmazonSalesRank()
      5. Recipe 95: PatternMatchWord()
      6. Recipe 96: SuggestSpelling()
      7. Recipe 97: AnagramFinder()
      8. Recipe 98: CornerGif()
      9. Recipe 99: RoundedTable()
      10. Recipe 100: DisplayBingMap()
  11. Part III: JavaScript Recipes
    1. 13. The Core Recipes
      1. Loading the Recipes
      2. Recipe 1: O()
      3. Recipe 2: S()
      4. Recipe 3: Initialize()
      5. Recipe 4: CaptureMouse()
      6. Recipe 5: CaptureKeyboard()
      7. Recipe 6: FromKeyCode()
      8. Recipe 7: GetLastKey()
      9. Recipe 8: PreventAction()
      10. Recipe 9: NoPx() and Px()
      11. Recipe 10: X() and Y()
      12. Recipe 11: W() and H()
      13. Recipe 12: Html()
      14. Recipe 13: SaveState()
      15. Recipe 14: RestoreState()
      16. Recipe 15: InsVars()
      17. Recipe 16: StrRepeat()
      18. Recipe 17: HexDec()
      19. Recipe 18: DecHex()
    2. 14. Location and Dimensions
      1. Recipe 19: ResizeWidth()
      2. Recipe 20: ResizeHeight()
      3. Recipe 21: Resize()
      4. Recipe 22: Position()
      5. Recipe 23: GoTo()
      6. Recipe 24: Locate()
      7. Recipe 25: GetWindowWidth()
      8. Recipe 26: GetWindowHeight()
      9. Recipe 27: GoToEdge()
      10. Recipe 28: CenterX()
      11. Recipe 29: CenterY()
      12. Recipe 30: Center()
    3. 15. Visibility
      1. Recipe 31: Invisible()
      2. Recipe 32: Visible()
      3. Recipe 33: VisibilityToggle()
      4. Recipe 34: Opacity()
      5. Recipe 35: Fade()
      6. Recipe 36: FadeOut()
      7. Recipe 37: FadeIn()
      8. Recipe 38: FadeToggle()
      9. Recipe 39: FadeBetween()
      10. Recipe 40: Hide()
      11. Recipe 41: Show()
      12. Recipe 42: HideToggle()
    4. 16. Movement and Animation
      1. Recipe 43: Slide()
      2. Recipe 44: SlideBetween()
      3. Recipe 45: Deflate()
      4. Recipe 46: Reflate()
      5. Recipe 47: DeflateToggle()
      6. Recipe 48: DeflateBetween()
      7. Recipe 49: Zoom()
      8. Recipe 50: ZoomDown()
      9. Recipe 51: ZoomRestore()
      10. Recipe 52: ZoomToggle()
    5. 17. Chaining and Interaction
      1. Recipe 53: Chain(), NextlnChainQ, and CallBack()
      2. Recipe 54: Repeat()
      3. Recipe 55: While()
      4. Recipe 56: Pause()
      5. Recipe 57: WaitKey()
      6. Recipe 58: Flip()
      7. Recipe 59: HoverSlide()
    6. 18. Menus and Navigation
      1. Recipe 60: HoverSlideMenu()
      2. Recipe 61: PopDown()
      3. Recipe 62: PopUp()
      4. Recipe 63: PopToggle()
      5. Recipe 64: FoldingMenu()
      6. Recipe 65: ContextMenu()
      7. Recipe 66: DockBar()
      8. Recipe 67: RollOver()
      9. Recipe 68: Breadcrumbs()
      10. Recipe 69: BrowserWindow()
    7. 19. Text Effects
      1. Recipe 70: TextScroll()
      2. Recipe 71: TextType()
      3. Recipe 72: MatrixToText()
      4. Recipe 73: TextToMatrix()
      5. Recipe 74: ColorFade()
      6. Recipe 75: FlyIn()
      7. Recipe 76: TextRipple()
    8. 20. Audio and Visual Effects
      1. Recipe 77: Lightbox()
      2. Recipe 78: Slideshow()
      3. Recipe 79: Billboard()
      4. Recipe 80: GoogleChart()
      5. Recipe 81: PlaySound()
      6. Recipe 82: EmbedYouTube()
      7. Recipe 83: PulsateOnMouseover()
    9. 21. Cookies, Ajax, and Security
      1. Recipe 84: ProcessCookie()
      2. Recipe 85: CreateAjaxObject()
      3. Recipe 86: GetAjaxRequest()
      4. Recipe 87: PostAjaxRequest()
      5. Recipe 88: FrameBust()
      6. Recipe 89: ProtectEmail()
    10. 22. Forms and Validation
      1. Recipe 90: FieldPrompt()
      2. Recipe 91: ResizeTextarea()
      3. Recipe 92: ValidateEmail()
      4. Recipe 93: ValidatePassword()
      5. Recipe 94: CleanupString()
      6. Recipe 95: ValidateCreditCard()
    11. 23. Solutions to Common Problems
      1. Recipe 96: RollingCopyright()
      2. Recipe 97: Alert()
      3. Recipe 98: ReplaceAlert()
      4. Recipe 99: ToolTip()
      5. Recipe 100: CursorTrail()
      6. Recipe 101: TouchEnable()
  12. Part IV: CSS Classes
    1. 24. Manipulating Objects
      1. Recipe 1: Positioning
      2. Recipe 2: Floating
      3. Recipe 3: Background Colors
      4. Recipe 4: Gradients
      5. Recipe 5: Inverse Gradients
      6. Recipe 6: Box Shadows
      7. Recipe 7: Padding
      8. Recipe 8: Rounded Borders
      9. Recipe 9: Transparency
      10. Recipe 10: Visibility and Display
      11. Recipe 11: Scroll Bars
      12. Recipe 12: Maximum Sizes
      13. Recipe 13: Location
      14. Recipe 14: Selective Margins
      15. Recipe 15: Selective Padding
      16. Recipe 16: Border Style
      17. Recipe 17: Border Width
      18. Recipe 18: Border Color
      19. Recipe 19: No Outline
    2. 25. Text and Typography
      1. Recipe 20: Fonts
      2. Recipe 21: Font Styles
      3. Recipe 22: Text Alignment
      4. Recipe 23: Text Point Size
      5. Recipe 24: Text Colors
      6. Recipe 25: Text Shadows
      7. Recipe 26: Text Transformations
      8. Recipe 27: Encapsulation
      9. Recipe 28: Google Fonts
      10. Recipe 29: Drop Cap
      11. Recipe 30: Columns
      12. Recipe 31: Text Indent
      13. Recipe 32: Symbols
    3. 26. Menus and Navigation
      1. Recipe 33: Buttons
      2. Recipe 34: Vertical Menu
      3. Recipe 35: Horizontal Menu
      4. Recipe 36: Top Dock Bar
      5. Recipe 37: Bottom Dock Bar
      6. Recipe 38: Tooltip and Tooltip Fade
    4. 27. Page Layout
      1. Recipe 39: Reset CSS
      2. Recipe 40: Default CSS
      3. Recipe 41: Boxout
      4. Recipe 42: Quote
      5. Recipe 43: Left Sidebar
      6. Recipe 44: Right Sidebar
      7. Recipe 45: Page Break
    5. 28. Visual Effects
      1. Recipe 46: Star Rating
      2. Recipe 47: Star Rating Using Images
      3. Recipe 48: Progress Bar
      4. Recipe 49: Scale Up
      5. Recipe 50: Scale Down
      6. Recipe 51: Transition All
      7. Recipe 52: Thumb View
      8. Recipe 53: Caption Image
      9. Recipe 54: Pointer
      10. Recipe 55: Rotation
      11. Recipe 56: Odd and Even Text Colors
      12. Recipe 57: Odd and Even Background Colors
    6. 29. Dynamic Objects
      1. Recipe 58: NoJS (nojs) and OnlyJS (onlyjs)
      2. Recipe 59: Middle (middle)
      3. Recipe 60: Center (center)
      4. Recipe 61: Top (top)
      5. Recipe 62: Bottom (bottom)
      6. Recipe 63: Left (left)
      7. Recipe 64: Right (right)
      8. Recipe 65: On Demand (ondemand)
      9. Recipe 66: Fadein (fadein[n])
      10. Recipe 67: Fadeout (fadeout[n])
      11. Recipe 68: Resize Textarea (resizeta[n \ri\)
      12. Recipe 69: Rotate (rotate[n])
      13. Recipe 70: Width (w[n])
      14. Recipe 71: Height (h[n])
      15. Recipe 72: X (x[n])
      16. Recipe 73: Y (y[n])
      17. Recipe 74: Text Color (color[colorname/#nnnnnn/#nnn])
      18. Recipe 75: Background Color (bcolor[#nnnnnn])
    7. 30. Dynamic Text and Typography
      1. Recipe 76: Typetext (typetext[n])
      2. Recipe 77: Digits Only (digitsonly)
      3. Recipe 78: Text Only (textonly)
      4. Recipe 79: No Spaces (nospaces)
      5. Recipe 80: No Punctuation (nopunct)
      6. Recipe 81: Minimum Whitespace (minwhitespace)
      7. Recipe 82: Google Font (gfont[n])
      8. Recipe 83: Text Middle (textmiddle)
      9. Recipe 84: Text Glow (textglow[#nnnnnn|#nnnnnn|n])
      10. Recipe 85: Background Glow (backglow[#nnnnnn|#nnnnnn|n])
    8. 31. Dynamic Interaction
      1. Recipe 86: Placeholder (placeholder[prompt])
      2. Recipe 87: Autofocus (autofocus)
      3. Recipe 88: Cite (cite[citation])
      4. Recipe 89: Reference (ref[type|name])
      5. Recipe 90: No Copy (nocopy)
    9. 32. Incorporating JavaScript
      1. Recipe 91: Embed JavaScript (embedjs)
      2. Recipe 92: If (if[expr])
      3. Recipe 93: If Not (ifnot[expr])
    10. 33. Superclasses
      1. What Is a Superclass?
      2. Recipe 94: Clickable (clickable)
      3. Recipe 95: RSS Button (rssbutton)
      4. Recipe 96: Border (border)
      5. Recipe 97: Absolute Top Left (abstopleft)
      6. Recipe 98: Rollover (rollover)
      7. Recipe 99: Vertical Tab (vtab)
      8. Recipe 100: Horizontal Tab (htab)
      9. Summary
  13. Index