mt_rand.zip

How to make random number ?

524

Generate a random number using mt_rand.From the php documentation- "If called without the optional min,max arguments mt_rand() returns a pseudo-random value between 0 and RAND_MAX.If you want a random number between 5 and 15 (inclusive),for example,use mt_...

How to force cookies, disable php sessid in URL ?

562

This commands disables php from rewriting URLs to add a phpsessid, and forces the use of cookie sessions instead. Using cookies is largely thought of as the preferred way to use sessions - both more secure and better for SEO. This can be accomplished by se...

How to optimize MySQL automatically in CentOS Linux

1,009

I am using CentOS Linux for service purpose. Main reason to use CentOS is cheaper hosting for private purpose. Actually MySQL requires periodical optimization process in my experiences, and I use / etc / cron.hourly usually for those kind of bath processi...

SQL to Select a random row from a database table

539

There are lots of ways to select a random record or row from a database table.Here are some example SQL statements that don't require additional application logic,but each database server requires different SQL syntax.Select a random row with MySQL:Select ...

How to pass variables via url

473

Pass variables to a page using the question mark,for example mypage.php?value=hello.Access these variables with the _GET command.

PHP date and time formatting

435

The Smarty date_format function returns a formatted string showing date,time and / or seconds.index.php:index.tpl:sample output : .

How to get current filename as variable ?

773

Sometimes you need just the filename of the current script,without the path.This snippet does just that using the SCRIPT_NAME and explode function. Getting the Current Filename as a VariableHere's how to retrieve the current filename in your script::Unders...

email validation, simple

420

Let's assume a email validation function - returns TRUE or FALSE.Checks format only,does not use any networking functions to verify the account actually exists.

for loop - simple

450

for loop - basic control structure. This example loops until the variable hits 10 and then breaks out. 10) {       break;   }   echo $i;}?>sample output :12345678910

form action - detect form post

432

PHP provides super global variables which is available anywhere.1.$_POST Superglobal:- This array holds all data submitted via the HTTP POST method.It's the most common way to access form data.- To access a form field value,use the field name as the key: ....

How to include a file with error reporting ?

435

Sometimes you want to be able to give some feedback if a PHP include has failed.Here is a version using the fopen command,which can search the include path. Here's another example much better simple than the above.As you can see,just add @ in front of the ...

PHP form handling example in single page

425

This example shows a very simple form together with the form handling process on a single page. Below is another approach based on Heredoc I like:

How to get Referral URL ?

2,082

Grabs the referring URL - get the HTTP_REFERER and save it to a variable. code snippet: .While not inherently intended for API security,the HTTP_REFERER header can be a valuable tool for implementing an API that restricts access to certain resources based ...

How to convert formatted date time string to datetime?

450

Whatever the formatted string is,strtotime() function convert the formatted date time string to datetime.Following example shows the simple reference can convert date time string whatever the formatted input is.

Adding and Subtracting Time

562

The time () function generates a long string of numbers representing how many seconds have passed since January 1, 1970. It is possible to add and subtract time by adding and subtracting seconds.

The three simplest regular expressions you will use in PHP

587

The three most basic searches using regular expressions are searching for the strings start, the strings end, or for characters it contains. We can do these using the following symbols:^ indicates the string starts with the specified characters, so "^strcp...

Number Format

494

In this article we'll make number format like 0001, 0002, 0003 in stead of 1, 2 ,3. It's very easy to do this for your counter, category or product ID. etc.

A Function Returns Large Random Numbers

431

This basically randomly pick a number between the min and max values. This is made because the rand() and mt_rand() function can not accept numbers larger than 2^31 or 2^63,depend on your processor and complier.

Function AccountCryptPassword($password,$salt)

736

Encryption and password account accessFunction AccountCryptPassword($password,$salt) {  if($salt=="")  {   srand(time());   $random=rand();   $itoa64=". / 0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz"; ...

Cardinal Endings

502

This php based script will find numbers and give them a cardinal ending.This can be useful for displaying rankings or results of a competition.The script is easy to install and use .Explanation::addOrdinalSuffix($number): This function adds the appropriate...