PHP.zip

Human readable random string for captchas in PHP

564

CAPTCHAs (Completely Automated Public Turing test to tell Computers and Humans Apart) are challenges designed to differentiate between human users and automated bots.We use them primarily to prevent malicious activities like spam,fake account creation,and ...

Date format validation in PHP

574

Below code is designed for date format validation in PHP.Even though simple,but useful many times.Actually PHP provides date validation function as checkdate().See the detail below.

Posting to a Wordpress Blog Via XMLRPC Using Blogger API

772

RPCXML is now the standard widely using on earth.Microsoft Windows Live is also using RPCXML in order to post blog content.Actually there are lots of specification for posting blog stuffs: Metaweblog API,Blogger API,and so on.Following is the simple exampl...

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...

PHP Switch Example

431

The PHP switch method provides a clean and efficient way to execute different blocks of code based on the value of a variable or expression.It offers a structured alternative to multiple if-else statements,simplifying code readability and maintenance.The s...

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 ...

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 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 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 ...

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.

How to upload attachments such as image by metaWeblog API ?

393

Actually this is one of the very important feature to post blog stuffs by metaWeblog API.Followings are the simple example of posting attachment by metaWeblog API.Actually the unique filename should be passed as third parameter,but the blow sample code aut...

How to post blog content by metaweblog API ?

490

"metaweblog API" is very usefull when you want to post content automatically or periodically.For example,if you are planning to release news letter by collecting the recent articles on your blog,this is very useful tool.The below module is available with t...

ISO 8601 format time format string conversion

542

When communicating with XML,ISO 8601 format time string is used.In case of using xmlrpc,it contains ISO 8601 format time string conversion module such as iso8601_encode,and iso8601_decode.If you don't use xmlrpc module,you can declare below module in order...

XMLRPC example

766

XML-RPC (XML Remote Procedure Call) is a remote procedure call protocol that uses XML to encode data and HTTP to send it over a network.It allows programs running on different systems to communicate with each other by invoking procedures on a remote server...

HTML redirection in PHP

400

HTML redirection,in the context of PHP,involves using the `header()` function to send an HTTP redirect header to the browser,instructing it to load a different URL.This is typically achieved by setting the `Location` header to the target URL.For instance,`...

File downloading via HTTP

449

When making blog or BBS,usually we use hyper link as following:But above example may not working in case that the platform is multi-byte character based web page.Now a days,following method is widely used for security reason.Actually following method is tr...

Get the actual filesize for a size above 2GB in Windows

435

If you want to get the actual filesize for a size above 2GB in Windows,you can use the COM-extensions in PHP.An example is as follows:This will return the corrent filesize.And it is very useful with PHP-GTK applications,where you want to use the filesize f...

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 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 : .

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...

URL Rewriter PHP

624

URL Rewriter PHP is a short code that can be used to rewrite dynamic PHP urls as URL's that link to static htmlpages.Increases search engine rankings by creating a static system of page linking as well as making all content available. Associated Data for U...

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.