You Are Here: Home »   Codelist Wednesday October 8th 2008

Code Library

PHP Code

Add text to text file
2334 Views - Added By face

Easy way to add some text to text file. You can use it like guestbook ;)

Alternate Row Colors
1964 Views - Added By Matt

Alternate table row colors with php

Ascii Characters
1460 Views - Added By Anonymous

Function to output all 256 ascii characters

Basic Site Stats
2420 Views - Added By Anonymous

Logs all hits in the format: day,date,time,ip,browser,referer, to a text file

Check Database Value
1386 Views - Added By Anonymous

Simple function to check if a value exists in a database, most useful from a form.

Connect To Mysql
1695 Views - Added By Anonymous

Making a connection to your mysql database using php

Directory List
1838 Views - Added By Anonymous

Echo all files in a particular directory

Directory Search
1458 Views - Added By Anonymous

This is a simple directory search i wrote for here to search the php manual, it will search the filenames in the directory, not the files themselves

Directory Total
1317 Views - Added By Anonymous

Count the total number of files in a directory

Explode
1699 Views - Added By zDos

simple code using explode();

Folder List
1270 Views - Added By Anonymous

Echo all folders in a particular directory

Hex Colour Table
1124 Views - Added By Anonymous

This was a javascript function that i found ages ago, but the W3C validator didn't like it, so i re-wrote it in PHP, no idea who made the original one. It's the same as the colour table used here.

Highlight Syntax
1392 Views - Added By Peter007

Highlight PHP Syntax

Hit Counter
1957 Views - Added By Anonymous

Display the number of hits to your website

Html Email
1784 Views - Added By Anonymous

Basic format to send a HTML email

Html ereg
1161 Views - Added By Pepper

to check if code contains <html> tags it will go true if it contains anything like <something>

If thingy
1285 Views - Added By Pepper

Learning if an Get properly take a look here :)

IP Logger
1968 Views - Added By Anonymous

Log visitors ips and time/date of visit in a simple text file

Last 5 Referers
2053 Views - Added By Anonymous

Display the last 5 referers to your site on your homepage

Lines In A File
1069 Views - Added By Anonymous

An easy way to return the number of lines in a file

Link Validator
1269 Views - Added By Anonymous

Basic script to check if a link (url) is valid

Multiple Page Lists
1524 Views - Added By Anonymous

Splitting an amount of MySQL data onto multiple pages.

Page Generation Time
1617 Views - Added By Anonymous

Display "this page was generated in x.xxxx seconds" on your pages

Quick Site Check
1222 Views - Added By Anonymous

Check if a certain site or server is up by opening a simple socket

Random Image
1424 Views - Added By Pepper

Random Image script

Random Link
1081 Views - Added By Anonymous

Display a link or line of text from a selection at random

Random Password
1279 Views - Added By Anonymous

Function to generate a random alphanumeric password

Return File Extension
939 Views - Added By Matt

Simple function to return the extension of a file, suitable for just filenames, not webpath/filename

Reverse Code
1152 Views - Added By zDos

file reversal code.. good for tagboards.

See your IP
1779 Views - Added By Tyler's Network

Shows people thier IP

Server Path
1151 Views - Added By Anonymous

An easy way to get your full server path when installing php scripts

Simple Birthday code
1460 Views - Added By Z!plink

Tells you when your friends have birthday!

Split Number
984 Views - Added By Anonymous

Quick example of how to split a number into two values using substr()

Switch Function Replacement
1299 Views - Added By Anonymous

For people using the switch function for their pages like ?page=blah, if you have alot of pages this is a much shorter way to include them as they are called

Switch Replacement2
1287 Views - Added By Pepper

Switch replacement diffrent from other

Time And Date
4185 Views - Added By Anonymous

A selection of examples for displaying time & date

Validate Email
1441 Views - Added By Anonymous

Function to check an email address is a valid format

Wildcard IP Deny
1520 Views - Added By Anonymous

Deny access to a specified IP, allows you to use * wildcards, to help stop people who's ip's change each time they reconnect


Javascript Code

Add Bookmark
1438 Views - Added By Anonymous

A simple snippet so visitors can add your site to their favorities

Alert Once Box
1202 Views - Added By Anonymous

Pop up a message alert box for your visitors, that they only see on the first visit

Block Errors
1068 Views - Added By Anonymous

This will block the "done but with errors on page" message that you sometimes get on the statusbar

Break Out Of Frames
1032 Views - Added By Anonymous

Stop your website getting trapped in a frame (forces the window ontop)

Check Radio Buttons
1105 Views - Added By Anonymous

Simple function to loop through a number of radio buttons in a form to see if one is checked

Custom Cursor
1330 Views - Added By Anonymous

Allows you to use a custom mouse cursor on your site

Email encode
1143 Views - Added By t43

This javascript will encode an email however still let mailto: work with it :)

Extra Button(Proboards)
1359 Views - Added By Anonymous

This lets you add an extra button to the top menu bar, so you can add a button to link to your website homepage, chatroom or whatever

Guest Redirect(Proboards)
1024 Views - Added By Anonymous

Redirects guests on your proboards forum to the register page, this is a heavily modified version of a non-working code i found at support.proboards.com (place in your main header)

Hide Show Layers
1729 Views - Added By csyntax

Ability to hide and show elements of a html page.

MailForm
1604 Views - Added By Anonymous

A basic html mail/contact form layout

Page Refresh
1185 Views - Added By Anonymous

Let visitors refresh your page from a button, usefull if you display some random content

Play Music
1642 Views - Added By Anonymous

Code to play an mp3 file as background music on your site

Popup Window
1300 Views - Added By Anonymous

Create a simple popup window, you can easily edit the size and other attributes

Random Page
904 Views - Added By Skynet

Put this code in your page, and you will goto one of 3 pages you assign

Redirect Page
1059 Views - Added By Anonymous

Automatically redirect people to a certain page when the visit another

Rules Popup(Proboards)
953 Views - Added By Anonymous

This mod can display your rules thread in a popup window when a new user clicks the registration page

Set As Homepage
1059 Views - Added By Anonymous

Let visitors set your site as their default homepage

Shake Browser
1138 Views - Added By Skynet

When you click an assigned button, it shakes your browser and everything on the page

Show And Hide Content
1492 Views - Added By Anonymous

Use this for collapsible menus or any content you want to show/hide from a link

Time And Date JS
4084 Views - Added By Anonymous

Display the current time & date on your website

View Page Source
1200 Views - Added By Anonymous

Pop up the source of the page from a link. (IE/Mozzila)

Window Popup
1139 Views - Added By FiRe

When the page loads make a window popup.