Archive: tutorial
-
Aug 29, 2011
Comments OffCanada’s postal code validation in PHP
Few days back, My friend Narendra asked me how to validate the postal code of Canada which is entered through the text box.And, I came up with this Php function as solution for him. These are the conditions for validation of the postal code of Canada. There are six alphanumeric letters. Alphabate and digits...
-
Aug 29, 2011
Comments OffTextbox to accept only numbers (digits) using jquery
Few days back, my friend Parleen asked me how can we make a textbox which just accepts only numbers specially digits only. And, for his I come up with this solution of textbox which only accepts digits, and if you try to enter any alpha bates in it then it displays the error message with...
-
Aug 29, 2011
Comments OffIp address validation in PHP using regular expression
If you don’t know how to validate the IP address format in PHP, then you are in the right place.I’ll show you here how to validate the IP address using regular expression in PHP. As you guyz know, IP address consists four parts. Each parts separated by period “.” and these part consists the...
-
Aug 29, 2011
Comments OffHow to do Date format validation in PHP
Today Sushil asked me how can we validate the date which is entered from textbox in “YYYY-MM-DD” format. Well, we can validate the format of the date using regular expression but how to validate weather that date is valid date or not, such as “2007-02-29″ is the correct format of the date but it’s not...
-
Aug 29, 2011
Comments OffUnderstanding and Validating Integers in PHP
I’ve found many of my friends struggling with the validation of integers i.e. the numbers with only digits in PHP. Some of them were wondering why is_int() or is_integer() functions of PHP sometimes works and sometimes won’t. If you become clear with the concept of integer and string in PHP then you’ll obviously come...
-
Aug 29, 2011
Comments OffHow to disable the Enter key on HTML form
Normally when you have a form with several text input fields, it is undesirable that the form gets submitted when the user hits ENTER in a field. Some people are pressing the enter key instead of the tab key to get to the next field. They often do that by accident or because they are...
-
Aug 29, 2011
Comments OffHow to install and configure PHP 5 on Windows box
It is assumed that you have already successfully setup IIS or installed Apache on your machine and configured it. So, to configure PHP and secure its correct operation you need to go through a couple of steps. Download and unzip the latest version of PHP Rename/copy php.ini-recommended to php.ini Create a session state directory and...
-
Aug 29, 2011
Comments OffHow to Send Email (Text/HTML/Attachments) in php
Email is the most popular Internet service today. A plenty of emails are sent and delivered each day. The goal of this tutorial is to demonstrate how to generate and send emails in PHP. So, you want to send automated email messages from your PHP application. This can be in direct response to a user’s...
-
Aug 29, 2011
Comments Offhow to work with Directories in php
As is necessary for any language, PHP has a complete set of directory support functions. PHP gives you a variety of functions to read and manipulate directories and directory entries. Like other file-related parts of PHP, the functions are similar to the C functions that accomplish the same tasks, with some simplifications. This tutorial describes...
-
Aug 29, 2011
Comments OffHow to connect to MS SQL Server database
Below is the code for connecting to a MSSQL Server database. <?php $myServer = “localhost”; $myUser = “your_name”; $myPass = “your_password”; $myDB = “examples”; //connection to the database $dbhandle = mssql_connect($myServer, $myUser, $myPass) or die(“Couldn’t connect to SQL Server on $myServer”); //select a database to work with $selected = mssql_select_db($myDB, $dbhandle) or die(“Couldn’t open database...
-
Aug 29, 2011
Comments OffHow to make DSN and DSN-less connections
DSN stands for ‘Data Source Name’. It is an easy way to assign useful and easily rememberable names to data sources which may not be limited to databases alone. If you do not know how to set up a system DSN read our tutorial How to set up a system DSN. For our example below...
-
Aug 29, 2011
Comments OffBlocking access to the login page after three unsuccessful login attempts
Sometimes you need to add an extra protection to password-protected website. This article explains how access to the login page can be restricted after three unsuccessful login attempts. This schema uses visitors IP address to store log attempts in the database and block access to login feature for 30 minutes after third unsuccessful attempt. There...
-
Aug 29, 2011
Comments OffHow to Encrypt Passwords in the Database
If you are developing a password-protected web site, you have to make a decision about how to store user password information securely. What is “secure,” anyway? Realize that the data in your database is not safe. What if the password to the database is compromised? Then your entire user password database will be compromised as...
-
Aug 29, 2011
Comments OffHow to Create CAPTCHA Protection using PHP and AJAX
Download Source CAPTCHA is a simple test to determine if a user is a computer or a human. It is used to prevent spam abuse on the websites. So if you use CAPTCHA on your web site forms, this can help in stopping some bots and making life harder for other bots in accessing or using your...
-
Aug 29, 2011
Comments OffHow to Pass JavaScript variables to PHP
JavaScript is mainly used as a client side scripting language, while PHP is a server side technology. Unlike Java or ASP.Net, PHP doesn’t have tools to make it work client side. That is why you need to combine JavaScript and PHP scripts to develop powerful web-applications. One of the frequent problems is defining visitor’s screen...
-
Aug 29, 2011
Comments OffHow to Get the Current Page URL
Sometimes, you might want to get the current page URL that is shown in the browser URL window. For example if you want to let your visitors submit a blog post to Digg you need to get that same exact URL. There are plenty of other reasons as well. Here is how you can do...
-
Aug 29, 2011
Comments OffPHP: Export Database Schema as XML
Sometimes it can be useful to have a dump of the current database schema. The script below reads the schema from a MySQL database and outputs XML that describes the schema. At first we connect to a MySQL database and use the SHOW TABLES command to return all the tables in the database. Next, we iterate over each...
-
Aug 29, 2011
Comments OffHow to Create Thumbnail Images using PHP
Download Source This tutorial will describe how to create thumbnail images on the fly using PHP. Furthermore you will learn how to process a whole folder of images and create their thumbnails. Since this requires the GD library, you will need an installation of PHP with at least GD 2.0.1 enabled. Below we will create...
-
Aug 29, 2011
Comments OffUsing Regular Expressions with PHP and with advance php
Regular expressions are a powerful tool for examining and modifying text. Regular expressions themselves, with a general pattern notation almost like a mini programming language, allow you to describe and parse text. They enable you to search for patterns within a string, extracting matches flexibly and precisely. However, you should note that because regular expressions...
-
Aug 29, 2011
Comments OffReading the “clean” text from DOCX and ODT
In this article we will resolve the task of reading the “clean” text from the Office Open XML (more known as DOCX) and OpenDocument Format ODT using PHP. Note that we are not going to apply any third-party software. You might ask, why do that? And rightly so. The clean text received from DOCX or...