Recommended:

  • phpclasses.org
  • jsclasses.org
  • jsmag.com
  • siteapps.com
  • View our reviews on Hot Scripts
  • JS Tutorial
  • scripts.com
  • securesignup.com




Recent Comments

Powered by Disqus




is.gd API to shorten your links

There is a website http://is.gd/ that allows you to shorten you links. To do it, you can use this function: <?php function get_url($url) { //checking if curl is available if(in_array ('curl', get_loaded_extensions())) { $ch = curl_init(); $timeout = 5; ...

Comments Read more

Measure page loading time using javascript

You can use javascript to measure how long does it take to load your page. It's pretty simple. Get time when your page started to load, get time when it's done and do some math. To get starting time, we need to measure it right after page started to load, it is right after opening <head> tag: <script...

Comments Read more

jQuery and Mootools conflict

Since both jQuery and Mootools use symbol $ in their syntax, every time you'll use both of them you'll get a conflict. Web browser won't know to which function you are referring to. To avid this, you can use jQuery no conflict mode. To enable it, you need to put this in your code: <script type="text/javascript"> ...

Comments Read more

Creating your own CAPTCHA

To create your own CAPTCHA you need to create file that will generate CAPTCHAs image, let's call it img.php. Then put this content inside it: <?php session_start(); // function to create random pixels function imageset9pixel($image,$x,$y,$color){ for($i=$x-1;$i<$x+1;$i++){ ...

Comments Read more

TTF to GD

How many times you've found a good looking font, but couldn't use it because it was a True Type Font and no GD font which PHP uses. You can convert ttf fonts to gdf wants using this program: http://www.wedwick.com/wftopf.exe or using this site: http://www.lunar.lu/ttf-to-gdf/convert.php

Comments Read more

Making IE behave like normal browser

There is one cool javascript library that will make IE behave like normal browsers. It fixes many HTML and CSS issues like using CSS selectors (pseudo classes) and of course fixes transparent PNG problem in early IE versions. And it's all by downloading one simple file and adding between <head> </head> tags simple...

Comments Read more

Display users online without database

How to display users online without storing sessions in database? Simple, just count how many session files there are in session folder. No database required. Just change session path if you are on a shred hosting (you don't want to display all users from all websites) and call this simple function: <?php //change sessions path if you...

Comments Read more

Flash elements over CSS menu

Sometimes when you have CSS based navigation, it just doesn't work right with embedded flash elements. To fix this, all you have to do is to set attribute wmode to transparent. But what if you have a CMS, where you can't control user input and you can't ask users to modify code. Then this function will help: function...

Comments Read more

How to stop bots, antibot practices

The simplest way is to create an input in form, and hide it using CSS. Because no human can see it, so it should be aways empty. Lazy bots that are filling forms, are filling usually all fields, so you can just check if hidden input is filled, then it must be a bot. A bit more complex, but also more secure way is to create CAPTCHA...

Comments Read more

Preventing SQL Injections and Cross-Site Scripting

To secure your site from SQL Injections and Cross-Site Scripting you must validate every user input  field. And don't forget about url adress, you must verify $_GET data, too. There is a simple way to do this, without checking every user input. You can do all with this function: <?php //$arr array to be checked, $html -...

Comments Read more

Make dynamic form using javascript

Simple function to make form with one hidden value and submit this form. It can be used for deleting elements, or changing status from one to another. It takes 3 parameters val - value to be submitted (usually ID of record in database), name - key of the post variable (like $_POST['name']) and attach - id of any div to attach form,...

Comments Read more

External links

Simple javascript function that goes through all "a" tags and checks if attribute "rel" is set to "external". If yes, then function automatically ads target="blank" attribute thus opening link in new window. function externalLinks() { var anchors = document.getElementsByTagName("a"); for...

Comments Read more

function br2nl()

I bet you know about nl2br(), when you enter text in <textarea> element and then want to display contents of it as HTML, to get same line breaks, you'll have to use nl2br function. But what i you want to do completely opposite? You have text with different <br>, <br/> <br />  tags and you want to display it in...

Comments Read more

Crop data from database or Read more feature

So, for example, you have blog with news, and you want to do a preview page with all the news cut to 250 characters and Read more link at the end of each preview. To make it more difficult, you have this data with HTML code and unicode characters, so you can't cut in the middle of unicode char. This function will...

Comments Read more

Measuring PHP script execution time

To measure script execution time we need to get time when script started, time when ended and do simple math. To do that we put this code in the beginning of PHP script: <?php $time = microtime(); $time = explode(' ', $time); $start = $time[1] + $time[0]; ?> And this one in the end: <?php $time =...

Comments Read more

Simple recursive function to print out database tree structure

Simple function for database model ID, name, parent, where ID is unique identifier, name - any needed attributes etc, parent - unique identifier of parent where this element is attached to. I am just using my mysql class, you will have to modify it to yours <?php function print_menu($id = 0) { // get all records from database whose...

Comments Read more



1 2 3 4 5 6 7 8 9 10 11